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

Report - Nodata Event - Print message on report 1

Status
Not open for further replies.

jethro11

Programmer
Sep 11, 2002
18
US
Hi,
I currently have a report where if there are no records matching the criteria (obtained from user input), a messagebox comes up saying "No data available for(user input)". Is there any way that this message can be written out to the report? The Report_Nodata event is based upon no records being available so it won't work using this subroutine? Thanks for any suggestions!
 
Hi!

I think that subroutine might be used, but without the cancel=true and msgbox.

Consider adding an unbound textbox to your report, call it for instance txtNoData

In the On no data avent, use

[tt]me!txtNoData="Your custom message of no data"[/tt]

HTH Roy-Vidar
 
You can create a text box with a control source of:
=IIf(Not HasData,"No data...","")

Duane
MS Access MVP
 
RoyVidar and dhookom ,
Thanks so much for your suggestions, I did try setting up an unbounded text box on the report and it worked. But the problem is that the other parts of the report still show up (column headings, etc). No records are displayed obviously but the column headings and the total fields all appear along with my text box. How do I turn the other stuff off and have only the unbounded text box displayed when no records match the criteria.Thanks again for taking the time to answer my question!
 
Hi again!

To my limited knowledge, thats how a report is supposed to behave;-)

You could of course go thru the report controls (or rather sections), setting their visible properties = false... (in the no data event - and 'xept the section where your "nodata" textcontrol resides), for instance:
[tt]me.detail.visible=false
...[/tt]

But the message box in the no data event is what's usually preferred.

Unless someone else have a better solution.

Roy-Vidar
 
To hide page headers, create a new primary grouping and sorting level on the expression:
=1
Set the Group Header to yes for this grouping. Open the properties for the =1 Group Header and set the Repeat Section to Yes. Use this new section in place of your Page Header. If your report has no data then this "pseudo" page header will not show.

Other sections will need to be hidden with code.

Duane
MS Access MVP
 
Place an invisible label or textbox to display what you want.
Then, a loop like:

For Each ctr in Me.Controls
ctr.Visible=Not ctr.Visible
Next

will display only the invisible controls. If you have other invisible controls on the report, you can use another approach:

For Each ctr in Me.Controls
ctr.Visible=False
Next
Me("ControlWithText").Visible = True

Good luck


[pipe]
Daniel Vlas
Systems Consultant

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top