Catch error on open report

DoCmd.openReport "ThisWeekPayReport", acViewReport, , , acDialog

The above command is fired by a button on a form. The data source of the report has a criteria of employee number. Once the button is clicked Access opens a dialog box titled "Enter Parameter Value".  If an incorrect number is entered how can I catch it?

Is there some kind of an OnError condition that I could place the DoCmd inside of that would catch it if an incorrect number was entered?

Gary SamuelsPlant ManagerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
<<If an incorrect number is entered how can I catch it?>>

  You can't.  What you need to do is setup a form to collect the employee number using something like a combo, so they are forced to pick a valid number.

  Then call the report and have it's recordsource look to the form control to get the correct value. i.e.


 replacing everything in the <> (and including them) with the correct values.



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Gary SamuelsPlant ManagerAuthor Commented:
I was afraid of that.

Gary SamuelsPlant ManagerAuthor Commented:
If I wanted to use a textbox and verified the input.
Could I add the Filter and Where parameters to the DoCmd.openReport statement to accomplish the same thing?

Something like:
DoCmd.openReport "ThisWeekPayReport", acViewReport,Filter=[EmployeeNumber] ,WHERE=textbox.value , acDialog
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.