don't won't report to open if message box appears saying no data for report

I started a new job 3 weeks ago and I was given a problem of removing #error when no data is available . I solved this by using "On No Data " event to use a message box to inform the user but now after clicking "OK" it says run time error "2501" " The OpenReport event was canceled do I need a " and if " or some such thing ?
Kirk saintSoftware Designer(Trainee)Asked:
Who is Participating?

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

x
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:
In the code that calls the report you must add an error handler and check for error 2501.  If it’s encountered then you just ignore it.

Jim
0

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
Kirk saintSoftware Designer(Trainee)Author Commented:
yes tried that but it keeps going to a separate open event in another part of the code
0
Kirk saintSoftware Designer(Trainee)Author Commented:
0
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
In your Command4 procedure:

At the  start of the procedure:

  On Error Goto Error_Procedure

at the bottom,  add this:

Exit_Procedure:

     Exit Sub

Error_Procedure:
    If err.number <>2501 then
        Msgbox  err.number & " - " & err.description
   End If

   Resume Exit_Procedure

 
 So if you get an error in procedure other than 2501, you'll get a message box.   If you get 2501 because the report open was canceled (due to no data), it will be ignored.

  I would have marked up the code itself, but you posted it as an image.   In the future, when posting code, copy/paste it right in to the comment and use the "code" option so it's formatted.   That will make it easier for you and everyone else in working with it.

Jim.
0
Kirk saintSoftware Designer(Trainee)Author Commented:
well thanks but it does appear that there are more problem then what I stated above . like it will return some results for the time period but when I go into design view then into preview layout it adds more results that where not in the first . so getting the correct results is my first problem .
0
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.