Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Test if SQL SELECT Query is empty 1

Status
Not open for further replies.

hcisteve

Technical User
Jan 12, 2005
47
US
I want to be able to do one action in my VBA code if my SQL SELECT query is NULL and another one if it isn't. To do this, I need know how to test my VBA SELECT code to determine if the SELECT statement is NULL. The code I want to test is:


SQL1 = "Select ID"
SQL1 = SQL1 + " FROM MyTable"
SQL1 = SQL1 + " Where ((MyTable.FirstSurvey <> Yes))"

CurrentDb.OpenRecordset SQL1

Steve
 
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset SQL1
If rs.BOF Or rs.EOF Then
MsgBox SQL1 & " is empty"
Else
MsgBox SQL1 & " returns " & rs(0)
End If

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top