Handling Parameters in Reports

Liz_I3

Well-known Member
Joined
Dec 30, 2002
Messages
647
Office Version
  1. 2016
Platform
  1. Windows
I have two questions about how to handle paramenter in a report (run from a query).

First - if I enter a paramenter that produces a recordset with no data , how do I stop the report from being previewed. I just want a Message to come up No records for the data specifiec. I was going to use the Nodata event but thats for printing, I want to stop it from being previewed

The second question is - one of my parameters is a date (shortdate) field that asks for a start date and and end date. If the date is mm/dd/yy and the user enteres dd/mm/yy I want it to check for a valid date and if it is not a valid date send a message "Please enter a valid date". How do you refer to the date being imput by the user (that is asked for in the perameter) in is case a date which is to match a biweeklydate field in a query?

I would be greatfull for tips

thanks
liz
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
First part of Quesiton:

Actually, I have used the NoData event to prevent
users from viewing a report in print preview mode.
Did you remember to cancel?

Private Sub Report_NoData(Cancel As Integer)
MsgBox " This Report is Empty. " & Chr(10) & _
" Please change the Criteria!", vbOKOnly, "Known Error"
Cancel = True
End Sub


Second Part of Quesiton:

I don't know of a way to "validate"
data when you use parameters in a report query.

However, I do know how to validate data on a form. My suggestion
would be to create a form that validates the dates before you open
the report. You could even present a nice calander for users
to click on (further simplifying validation).

Hope that Helps!
 
Upvote 0

Forum statistics

Threads
1,221,519
Messages
6,160,295
Members
451,636
Latest member
ddweller151

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top