Where to put a dcount when have query parameters

lehcarrodan

Registered User.
Local time
Today, 00:48
Joined
Feb 20, 2017
Messages
11
I'd like to open a report that requires parameter input but only open the report if the query returns values. (It's a sales report)

So I know I can use
If DCount("*", "qryWhatever") > 0 Then ...

but then it seems I need to input the parameters twice? Can I have this check done by the query itself?

Thanks for the help, hope this makes sense! I'm new here haha
 
You can use the no data event of the report to stop it if there are no records:

Cancel = True

though you have to trap for the 2501 error in the code that opens the report. To your question, most of us would use a form to gather the user input, and both your DCount() and query could get them from there.
 
Thank you, thank you! I will make a form for input. However what do you mean trap for 2501 error? How do I do that.
 
Okay prefect! Just so I understand what's happening.. There's an automatic error in this case 2501 that occurs when there's no data returned? And instead of displaying that message I'm putting my own?
 
More accurately, the error is returned when the opening of the report is cancelled. Yes, you'd put your own message there.
 

Users who are viewing this thread

Back
Top Bottom