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!

Not opening a report if there are no records 1

Status
Not open for further replies.

NHogan

MIS
Aug 23, 2001
40
0
0
CA
Currently, I am launching a report from a button on a form. There is a date field and I filter on the entered date on the report. Everything works fine, but if there are no records for a specific date, then it launches an empty report.

Can I give the user a message box saying that there are no records without launching the report? Please help
 
Before Opening the report check whether is there any record or not.Best way to do is.

dim strKeyField as string

strKeyfield=Dlookup("[Your Key Field]","[Your table or query]","Your criteria")
if Isnull(strKeyField) then
msgbox "No matching records"
else
'Open Report
end if
 
Thanks, that worked great. I had to change it around a bit but it's exactly what I was looking for.

If Isnull(Dlookup("[Your Key Field]","[Your table or query]","Your criteria"))
Msgbox "No matching records"
Else
Open Report
End If

Thanks again

 
For an alternate, I guess, cleaner way, see my response to the following thread:

thread703-412491
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top