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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SIMPLE QUESTION IF NO DATA IN REPORT

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hello all. I have a simple question I think. I have a report that has sub reports. One of the reports the main recordsource which is a query has no data. On the report I have a text box called CustID. I have code in the Detail_Format that does a SQL Query with a varialbe being passed CustID. How can I do a recordcount or something to say off the bat that if no data then Exit Sub. I tried Me.RecordSource.RecordCount did not work. I am getting a error when it hits CustID because its empty. Thanks all
 
There is a No Data Event in the report form. You can create a macro called No_Data_On_Report with 2 items: a Message Box("No Data on Report") and a Cancel Event. Then select that macro within the report form No Data Event.

Another option is to do a quick DLOOKUP or DCOUNT before the report is fired to see if the selection criteria produces any results before launching the report form. I've used this approach for a variety of reasons; mostly dealing with complex sub-reports. Steve Medvid
"IT Consultant & Web Master"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top