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

Report based on parameter query 1

Status
Not open for further replies.

DoctorJDM

Technical User
Apr 15, 2007
60
0
0
GB
Have a command button on a menu to launch a report rptHours based on a simple query qryHours that uses [Enter Start Date] and [Enter End Date] parameters to define a date range, as below.

PARAMETERS [Enter Start Date] DateTime, [Enter End Date] DateTime;
SELECT tblCoordinatorHours.Hours, tblCoordinatorHours.ActivityType, tblCoordinatorHours.HoursDate, qryExplorers.Name
FROM (qryCoordinators INNER JOIN (qryExplorers INNER JOIN tblCoordinatorHours ON qryExplorers.Name = tblCoordinatorHours.ExplorerName) ON qryCoordinators.StaffID = tblCoordinatorHours.StaffID) INNER JOIN tblHomeTypes ON qryExplorers.HomeType = tblHomeTypes.HomeType
WHERE (((tblCoordinatorHours.HoursDate) Between [Enter Start Date] And [Enter End Date]));

I'd like to check that that there are records in the selected date range and avoid running the report if not, otherwise it shows #Errors everywhere. Instead I'd put up a message 'No data in selected date range".

If it weren't a parameter query I could use DCount as the check. How do I do it with this query?
 
You can simply put

Cancel = True

in the No Data event of the report. You would also have to trap for error 2501 in the procedure that calls the report. You can add a message box in either place.

Paul
MS Access MVP 2007/2008
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top