UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Report With No Data, Access 2016    
 
   
whitechair
post Jun 24 2019, 05:17 PM
Post#1



Posts: 491
Joined: 26-June 08



I have a report that runs showing FMCSA inspections from the previous month. It is attached to an email as a PDF document and sent to our clients.

Occasionally there are no inspections and the report has no records. If this happens, I would like the report to show something to indicate this to the client, rather than just print empty.

Not a message box to me, but an actual default record that says: "No inspections last month!" Or something like this.

Any suggestions?

--------------------
Jeff Moseler
Access 2007
Go to the top of the page
 
June7
post Jun 24 2019, 06:06 PM
Post#2



Posts: 649
Joined: 25-January 16



I have a report with subreports and sometimes subreports do not have data so a textbox will display when subreport has no data - "No data for this category."

But there would always be something on the main report.

Will there be some header info on report even if there are no inspections?


This post has been edited by June7: Jun 24 2019, 06:09 PM

--------------------
Attachments Manager is below the edit post window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
DEBUG! DEBUG! DEBUG! http://www.cpearson.com/Excel/DebuggingVBA.aspx
Go to the top of the page
 
theDBguy
post Jun 24 2019, 06:26 PM
Post#3


Access Wiki and Forums Moderator
Posts: 75,713
Joined: 19-June 07
From: SunnySandyEggo


Hi Jeff. You could try using an unbound textbox on the report with something like:
CODE
=IIf([HasData],"","Nothing to report!")
(untested- sent from phone)

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
ITguaranteed
post Jun 24 2019, 06:41 PM
Post#4



Posts: 29
Joined: 19-June 19
From: Tasmania, Australia


Hi,

CODE
Private Sub Report_NoData(Cancel As Integer)
Dim c As Control
    For Each c In Me
        c.Visible = False
    Next
' label1 = the heading control in your report header
    Label1.Caption = "No Inspection Last Month"
    Label1.Visible = True
End Sub
Go to the top of the page
 
whitechair
post Jun 25 2019, 07:37 AM
Post#5



Posts: 491
Joined: 26-June 08



This is really helpful, thank you! I've never used the NoData Event. Learning something new!

I have a quick followup question, can I limit the For Each loop to controls in the detail section only?

Also, I noticed that the report doesn't save the settings for hidden controls, (when I open the report later, all of the hidden controls are visible) while other times I apply code to a control it does. Is there some kind of rule that applies to certain properties or something that I am missing? Just curious.

--------------------
Jeff Moseler
Access 2007
Go to the top of the page
 
ITguaranteed
post Jun 25 2019, 06:38 PM
Post#6



Posts: 29
Joined: 19-June 19
From: Tasmania, Australia


Hi Jeff,

You're welcome.

CODE
Private Sub Report_NoData(Cancel As Integer)
Dim c As Control
    For Each c In Me.Detail.Controls
        c.Visible = False
    Next
    Label10.Caption = "No Inspection Last Month"
    Label10.Visible = True
End Sub


>Also, I noticed that the report doesn't save the settings for hidden controls, (when I open the report later, all of the hidden controls are visible) while other times I apply code to a control it does.

The initial settings for controls properties are set in the property page. Changes made by the code are not kept after the report is closed.
There is a way to set properties permanently in a report (or form) but you need to open the form in code in design mode.
eg.
DoCmd.OpenForm MyReport.Name, acDesign


>Just curious.

Curiosity killed the cat. It can be fatal for databases too. Backup your database before experimenting with that one. smile.gif

Go to the top of the page
 
ITguaranteed
post Jun 25 2019, 09:11 PM
Post#7



Posts: 29
Joined: 19-June 19
From: Tasmania, Australia


Just an update,
If code has executed changing a control and you click into layout view, then alter the control manually (say by moving it) and then save the form that will make the code change permanent, which is annoying to say the least.
Moral avoid layout view.
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    18th July 2019 - 08:33 AM