Check for null records in Query

MickM

Registered User.
Local time
Today, 14:25
Joined
Jun 2, 2005
Messages
15
Hi,

new to VBA!

I am trying to get the syntax right for opening a query and checking for null records. If the result is nill I then want to run another query.

I keep getting errors. here is the code:

DoCmd.OpenQuery "Check_Date"

If IsEmpty("Check_Date") Then
DoCmd.OpenQuery "Append_EC_Totals(Trend)"
DoCmd.Close
else End

Any ideas appreciated.
 
IsEmpty() is a VBA function to check to see if a Variant variable has been initialized to a value.

....

So are you trying to see if the Query "Check_Date" has any records? and if not, then execute the query named "Append_EC_Totals(Trend)"?

If that is the case, then one method that should work for you would be something like this:

Code:
With CurrentDb
    If .OpenRecordset("Query_Date").EOF Then
        .Execute "Append_EC_Totals(Trend)", dbFailOnError
    End If
End With
 
Works Brilliantly!

Thanks very much.

Michael
 

Users who are viewing this thread

Back
Top Bottom