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
> Hiding Subreport If No Data, Then Show Label, Access 2007    
 
   
ayen
post Apr 10 2020, 03:40 AM
Post#1



Posts: 972
Joined: 9-May 13



Hello,

Can someone pls share a code to hide a subreport if no data and to show label..."no records filed"..

Thank u in advance.

Ayen.
Go to the top of the page
 
June7
post Apr 10 2020, 11:58 AM
Post#2



Posts: 1,413
Joined: 25-January 16
From: The Great Land


Example from my db. Code is behind main report. Code references subreport container control name.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me.lblOU.Visible = Not Me.ctrOU.Report.HasData
Me.lblCO.Visible = Not Me.ctrCO.Report.HasData
Me.lblRC.Visible = Not Me.ctrRC.Report.HasData
End Sub


This post has been edited by June7: Apr 10 2020, 12:00 PM

--------------------
Attachments Manager is below the edit post window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Go to the top of the page
 
RJD
post Apr 10 2020, 12:40 PM
Post#3


UtterAccess VIP
Posts: 10,513
Joined: 25-October 10
From: Gulf South USA


Hi ayen: Another way to look at this ... with a demo. The demo shows how you can do what you want in both a form and a report.

Here's the code for the report Detail ...

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If DCount("*", "[tblMyRecords_2]", "NZ([MainID],0)=" & Nz([MainID], 0)) > 0 Then
Me!txtNotice.Visible = False
Reports!rptMyRecords_1!srpMyRecords_2.Report.Visible = True
Else
Me!txtNotice.Visible = True
Reports!rptMyRecords_1!srpMyRecords_2.Report.Visible = False
End If
End Sub

You will, of course, have to adjust this for your object names. Just giving you some alternatives to study ...

HTH
Joe
Attached File(s)
Attached File  HidingSubreport.zip ( 33.02K )Number of downloads: 4
 

--------------------
"Each problem that I solved became a rule, which served afterwards to solve other problems."
"You just keep pushing. You just keep pushing. I made every mistake that could be made. But I just kept pushing."

Rene Descartes 1596-1650 (Mathematician and Philosopher)
Go to the top of the page
 
projecttoday
post Apr 10 2020, 01:23 PM
Post#4


UtterAccess VIP
Posts: 12,205
Joined: 10-February 04
From: South Charleston, WV


Have you tried the on no data event?

--------------------
Robert Crouser
Go to the top of the page
 
ayen
post Apr 10 2020, 07:12 PM
Post#5



Posts: 972
Joined: 9-May 13



Many thanks june7.
Go to the top of the page
 
ayen
post Apr 10 2020, 07:13 PM
Post#6



Posts: 972
Joined: 9-May 13



Many thanks joe..

Will make this ref handy.

Go to the top of the page
 
ayen
post Apr 10 2020, 07:15 PM
Post#7



Posts: 972
Joined: 9-May 13



Hi robert,

Nk i did not tried yet..

Thank you..
Go to the top of the page
 
RJD
post Apr 10 2020, 07:18 PM
Post#8


UtterAccess VIP
Posts: 10,513
Joined: 25-October 10
From: Gulf South USA


thumbup.gif

--------------------
"Each problem that I solved became a rule, which served afterwards to solve other problems."
"You just keep pushing. You just keep pushing. I made every mistake that could be made. But I just kept pushing."

Rene Descartes 1596-1650 (Mathematician and Philosopher)
Go to the top of the page
 
ayen
post Apr 11 2020, 03:12 AM
Post#9



Posts: 972
Joined: 9-May 13



Hi joe,

If i may allow, can you pls help me get this thing to work.. I am trying the below into a calculated control in my query, to filter my query data source of my report, but it seems i missed something.. it gives me empty result.

[Form ]![frmPrintMgr].[txtAgeFrom] AND [Form]![frmPrintMgr].[txtAgeTo]

I have a from (frmPrintMgr) with 2 textboxes to enter the age (from - to), and button to run the report.

Thank u in advance.

Ayen..
Go to the top of the page
 
RJD
post Apr 11 2020, 07:17 AM
Post#10


UtterAccess VIP
Posts: 10,513
Joined: 25-October 10
From: Gulf South USA


Hi Ayen: I would be able to help better if I could see the entire SQL of the query. However, assuming that what you posted is in the criteria of a field in the query (WHERE in SQL), you might try ...

Between [Forms]![frmPrintMgr]![txtAgeFrom] AND [Forms]![frmPrintMgr]![txtAgeTo]

Please note the addition of "Between" and the correction of "Forms" instead of "Form".

This assumes that the form is open when the report is opened, and that the two form controls have valid data.

If this does not work, please post your SQL, or better yet, attach your db (no sensitive data, zipped).

HTH
Joe

--------------------
"Each problem that I solved became a rule, which served afterwards to solve other problems."
"You just keep pushing. You just keep pushing. I made every mistake that could be made. But I just kept pushing."

Rene Descartes 1596-1650 (Mathematician and Philosopher)
Go to the top of the page
 
ayen
post Apr 11 2020, 08:47 AM
Post#11



Posts: 972
Joined: 9-May 13



Hi joe,

Thanks for your quick reply..

I managed to get it work..thank u..

Ayen
P
Go to the top of the page
 
RJD
post Apr 11 2020, 10:20 AM
Post#12


UtterAccess VIP
Posts: 10,513
Joined: 25-October 10
From: Gulf South USA


You are welcome. Continued success ...

Regards,
Joe

--------------------
"Each problem that I solved became a rule, which served afterwards to solve other problems."
"You just keep pushing. You just keep pushing. I made every mistake that could be made. But I just kept pushing."

Rene Descartes 1596-1650 (Mathematician and Philosopher)
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    30th May 2020 - 10:55 AM