check query prior to opening form (1 Viewer)

kobiashi

Registered User.
Local time
Today, 21:58
Joined
May 11, 2018
Messages
258
I have a problem that I think I have a solution to but don’t know how to write the code for it.

I have a button that opens a form, on this form there is a combo box that has a query attached to it, the number of records in this query can change and can return no results which is what it is designed to do, what I would like to do is if the query is empty to inform the user when he clicks on the button, that the combo box is empty, and not open the form.



What I thought was to check the query in an if statement, but I have no idea the code to check the query.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 04:58
Joined
May 7, 2009
Messages
19,245
you can use DCount() function to check your Query if it will return something or none:

If DCount("1", "yourQuery") > 0 'there is record
'open the form associated with the query
else
'show messagebox?
end if
 

kobiashi

Registered User.
Local time
Today, 21:58
Joined
May 11, 2018
Messages
258
you can use DCount() function to check your Query if it will return something or none:

If DCount("1", "yourQuery") > 0 'there is record
'open the form associated with the query
else
'show messagebox?
end if
thanks for the reply, do i need to open/run the query in order check the query?
 

Users who are viewing this thread

Top Bottom