Identify if query returns records (1 Viewer)

PaddyIrishMan

Registered User.
Local time
Today, 02:06
Joined
Jun 5, 2002
Messages
166
Hi all,
This is the process I'm following:

1. The user selects criteria from list boxes on a form then clicks a button.
2. A paramater query is built on the fly using the criteria selected.
3. A Form is then displayed using the query as it's recordsource.

Ok - I've done the above, my problem is; if the query returns no records; a blank form is displayed.
I'd like to handle this (using code) so that I know whether the query returns anything before displaying the form.

Any suggestions greatly appreciated.
Regards,
Patrick
 

DES

Technoweenie
Local time
Yesterday, 21:06
Joined
Apr 17, 2001
Messages
245
sure

Where you have the code to open the form you need to put in a check to see if anything has been returned by the query.

So I would do a Dlookup on the index field of the query. If the value of the Dlookup = null then I would pop up a message box stating there is no such match and then exit the sub.

It would look something like

Dim vTest

vTest = DLookup("[Index]","Query")
If IsNull(vText) then
Msgbox "No Matches"
Exit Sub
End If

Of course this would have to go before the line of code which is opening the form.
 

PaddyIrishMan

Registered User.
Local time
Today, 02:06
Joined
Jun 5, 2002
Messages
166
Thanks Des,
That was what I was looking for.

Regards,
Patrick.
 

DES

Technoweenie
Local time
Yesterday, 21:06
Joined
Apr 17, 2001
Messages
245
I suppose

You should have actually done a DCount but if it work it works
 

Users who are viewing this thread

Top Bottom