Check a form for no records

G

Guest

I have a command button in a form which opens another form that is bound to a
querry.
If this querry has no records I don't want the form to open but to display a
message instead.
Does anybody know a way to check the querry for records first and if there
are no records to stop the form from opening.
Thanks in advance
 
G

Guest

Hi Michalis,

Two methods come to mind. You can use the domain aggregrate function named
DCount, and conditionally open the form based on the value returned or you
can open a recordset in VBA code and test for recordcount > 0.

Domain aggregrate functions are certainly easier, but they're kind of like
candy. They may taste good (ie. be easy to use), but they're not necessarily
good for you (may slow down your database, especially if a network is
involved).

In either case, you wouldn't stop the form from opening....you would
conditionally open it only if there were records to display.


If my answer has helped you, please answer yes to the question that reads
"Did this post answer the question?" at the bottom of the message thread.


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________

:

I have a command button in a form which opens another form that is bound to a
querry.
If this querry has no records I don't want the form to open but to display a
message instead.
Does anybody know a way to check the querry for records first and if there
are no records to stop the form from opening.
Thanks in advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top