What to do when no results

Vispon

New member
Local time
Today, 10:06
Joined
Aug 23, 2007
Messages
5
Hi Guys I'm not really sure wether this should be in queries or forms (as not sure where the code needs to go) but heres the problem. i have a front end form (where the user has various drop down boxes to choose from) which then runs a query and outputs the results in another form.

At the moment when there are no results it just brings up a big grey empty box, which is annoying since I want to use custom close buttons and disable the red x. Is there any way that if there are no results the query could open a different form (where I'd put some kind of error message and navigation choices).

Any help would be appreciated.
 
If you have access to the query that you just ran, say its name is z, and it has some field named y, you can do this?

X = DCOUNT( "[Y]","Z" )

This would tell you if you had zero records. Then your form-click routine that runs your query in order to populate your sub-form could build the query and test it this way. You would know that the query did or didn't return anything.

If you do NOT have access to the query by a name because you aren't storing it, then there is still a way by opening a recordset based on that query string, then doing a recordset .MoveFirst, then a recordset .MoveLast, then check the recordset .Count property to see how many records were traversed.
 
Thanks for the responce

I do have access to the query however the users searching a range of things simultaneously, so it could be a combination of 12 different fields which results in no matching records.
 
If you have or can build a WHERE clause (minus the WHERE keyword), you can include that in the DCOUNT as the third, or CRITERIA, argument. Look up DCOUNT if you weren't sure about this.
 

Users who are viewing this thread

Back
Top Bottom