Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I check for no records

Status
Not open for further replies.

OldSlowDog

Programmer
Mar 11, 2002
36
0
0
US
I have a subform with a query as Recordsource. How can I tell there is no record matching the criteria in the query so I can display a "No record found" message to the user.
Thanks for helping.

Ed
 
hi Ed,

you could do this after querying:

Dim rst As Recordset
Dim totrec As Integer

Set rst = Me.RecordsetClone
totrec = rst.RecordCount

if totrec=0 then msgbox "no records"

regards Guido
 
Or you could use the DCount function:

If not DCount("[ID]", "Your query") then msgbox "no records"

whereas you need to replace ID with some field of your query.

Regards,
MakeItSo

Andreas Galambos
EDP / Technical Support Specialist
(andreas.galambos@bowneglobal.de)
HP:
 
Thank you all for the great help. You all have a nice day.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top