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

Do not Print Report if Query Returns No data/values 3

Status
Not open for further replies.

villsthearcher

Technical User
Oct 20, 2005
27
US
Hello,

I want to show a message, instead of opening a Report in Preview mode, with no data in it.

What I want is that if the Query returns No data/values then do not open Report instead show message, "There is no data available for the values provided, in the database".

Thanks,

Vijay

Thanks,
villsthearcher
 
Place your message box in the No_Data Event...

Example:

Private Sub Report_NoData(Cancel As Integer)
MsgBox "Sorry. No data available."
Me.Application.Quit
End Sub
 
TripleJHJO,

Where and how do I create this "No_Data Event" ?

Please help me, I am new to VBA.

Can you give me an example of creating this "No_Data Event" ? Like for which object should I create this event?

Sorry and Thanks again.



Thanks,
villsthearcher
 
Open the property sheet for the form.
Go to the Event tab.
Click inside the 'On No Data' box.
Click the Build button (tiny, has three dots on it).
Choose Code Builder.
The first and last lines of TripleJHJo's code will already be there.
Paste the rest of the lines in between the first and last lines.

 
Lilliabeth,

I was searching for this event on the Properties window for the Form. But surprisingly it does not have that
ON NO DATA event! It has events like ON ERROR, so on but not the one that you specified.

I even tried to simply copy and paste Triplejhjo's code in the VB code window, but it does not seem to work!

Thanks,
villsthearcher
 
Erm - we're talking about reports, aren't we;-)

... reports event tab thingie ...

though the quit thingie is a bit harsh, innit?

[tt] MsgBox "Sorry. No data available."
cancel = true[/tt]

Roy-Vidar
 
Lilliabeth,

I was looking at the Porperties for Report. I found the NO DATA event there. I was also going through some other websites and like you had mentioned, this event is available in the FORMS properties. But in mine (i am using access 2003) this event is found in the Report Properties.

Thanks a lot you and Triplejhjo.

Thanks,
villsthearcher
 
Sorry, said form, meant report.,

Other than that, steps were correct, weren't they?

In Access 2003, the property is 'On No Data'.

 
yes Lilliabeth..You were right!

No probs with the form..thingie [peace]

Thanks,
villsthearcher
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top