Report opening without record

moi

Member
Local time
Tomorrow, 02:35
Joined
Jan 10, 2024
Messages
273
I need help of my report, I based my report to a query, and i wanted if no record to display, a message popup "no records to display", close the msgbox, focus will go back to "printmgr" form control where my selection starts..

thank you for any help..
 
Use Dcount() on the report criteria before opening report.
Check record count of source on load of report. Exit report if zero.
 
Use the OnNoData event of the report to display your message.

You may also need to add error trapping in the event that opens the report to catch the 2501 error.
 
  • Like
Reactions: moi
Use Dcount() on the report criteria before opening report.
Check record count of source on load of report. Exit report if zero.
That would require the db to be queried twice - unnecessary in light of the Report_NoData event.
 
Use the OnNoData event of the report to display your message.

You may also need to add error trapping in the event that opens the report to catch the 2501 error.
Hi Pat,

Would you please expand, as a beginner, my knowledge is very limited.. Where is the "OnNoData" event, and the error "2501".

Appreciate your kind help on both of these.. Any link where i can get a good demo/sample, please.

Thank you.
 
Where is the "OnNoData" event
where all events are - in the property sheet events tab
1714522201478.png


and the error "2501".

this error can apply to many things (just google 'vba error 2501'). But you should have a message as well which tells you where to find it. Since you are talking about reports, my guess would be this link will be indicative
 
where all events are - in the property sheet events tab
View attachment 113942



this error can apply to many things (just google 'vba error 2501'). But you should have a message as well which tells you where to find it. Since you are talking about reports, my guess would be this link will be indicative
Thanks CJ_London, I will check the link and see if i get to work.
 
2501 is not really an error. That's why in the Northwind 2 Developer Edition template's central error handler we write:
If lngError = 2501 Then Exit Sub '2501 = The OpenForm or OpenReport action was canceled. Not really an error.
 

Users who are viewing this thread

Back
Top Bottom