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

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
2 Pages V  1 2 >  (Go to first unread post)
   Reply to this topicStart new topic
> Make Report Visible, Access 2016    
 
   
mike60smart
post Feb 21 2020, 04:39 PM
Post#1


UtterAccess VIP
Posts: 13,729
Joined: 6-June 05
From: Dunbar,Scotland


Hi Everyone

I am trying to make a Report Visible based on the following Report Reference:-

CODE
=IIf([Reports]![rptAIAforPeriod]![rptSummaryforReportsubreport].[Report]![CoNo] Is Null,0)


The Control "CoNo" does not contain any value but the Report Reference displays Blank.

When I try to make a Report Visible using the following On Load Event I get the following error:-

Attached File  error.PNG ( 2.68K )Number of downloads: 0


Can anyone see where I am wrong with this?

Any help appreciated.

The Code is:-

CODE
Private Sub Report_Load()

10        On Error GoTo Report_Load_Error
20    If Me.txtCheck Is Null Then
30    Reports!rptAIAforPeriod!rptSummaryforReportBlanksubreport.Visible = True
40    End If

50    If Me.txtCheck > 0 Then
60    Reports!rptAIAforPeriod!rptSummaryforReportsubreport.Visible = True
70    End If


          
80        On Error GoTo 0
90        Exit Sub

Report_Load_Error:

100       MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Report_Load, line " & Erl & "."

End Sub

--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
June7
post Feb 21 2020, 05:03 PM
Post#2



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


Use IsNull

If IsNull(Me.txtCheck) Then

Either Is Null or IsNull() should work in textbox expression. What should return if not Null?

=IIf([Reports]![rptAIAforPeriod]![rptSummaryforReportsubreport].[Report]![CoNo] Is Null, 0, something else)

This post has been edited by June7: Feb 21 2020, 05:12 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
 
pere_de_chipstic...
post Feb 22 2020, 06:18 AM
Post#3


UtterAccess Editor
Posts: 10,594
Joined: 8-November 07
From: South coast, England


Hi Mike

You are looking to hide a sub-report based on a value in that sub-report (CoNo) - is that correct?

But you are checking a control on the parent form (Me.TxtCheck).

How does Me.TxtCheck reflect the control CoNo in the sub report?

You could replace (though this doesn't answer the question above)
CODE
20    If Me.txtCheck Is Null Then
30    Reports!rptAIAforPeriod!rptSummaryforReportBlanksubreport.Visible = True
40    End If

50    If Me.txtCheck > 0 Then
60    Reports!rptAIAforPeriod!rptSummaryforReportsubreport.Visible = True
70    End If

with
CODE
Me.rptSummaryforReportBlanksubreport.Visible = Not NZ(Me.txtCheck, 0) = 0

The code assumes that this is in the on load event for the report "rptAIAforPeriod"!

hth
This post has been edited by pere_de_chipstick: Feb 22 2020, 07:19 AM

--------------------
Warm regards
Bernie
Go to the top of the page
 
Jeff B.
post Feb 22 2020, 07:10 AM
Post#4


UtterAccess VIP
Posts: 10,409
Joined: 30-April 10
From: Pacific NorthWet


Where are you trying to do this? On a form, a report, ...

--------------------
Regards

Jeff Boyce
Microsoft Access MVP (2002-2015)

Mention of hardware or software is, in no way, an endorsement thereof. The FTC of the USA made this disclaimer necessary/possible.
Go to the top of the page
 
mike60smart
post Feb 22 2020, 08:22 AM
Post#5


UtterAccess VIP
Posts: 13,729
Joined: 6-June 05
From: Dunbar,Scotland


Hi Everyone

txtCheck is an Unbound Control on a Main Report which is making reference to the Control 'CoNo"

CODE
=IIf([Reports]![rptAIAforPeriod]![rptSummaryforReportsubreport].[Report]![CoNo] Is Null,0,"")


The above IIf displays "0" as required.

The On Load Event of the Report does not display the SubReport as expected:-

CODE
20    If Me.txtCheck = 0 Then
30    Reports!rptAIAforPeriod!rptSummaryforReportBlanksubreport.Visible = True
40    End If

50    If Me.txtCheck > 0 Then
60    Reports!rptAIAforPeriod!rptSummaryforReportsubreport.Visible = True
70    End If

--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
pere_de_chipstic...
post Feb 22 2020, 08:38 AM
Post#6


UtterAccess Editor
Posts: 10,594
Joined: 8-November 07
From: South coast, England


Hi Mike
Being on a subform, it may be that the subform is not instantiated before the main form's on load event fires.

In this sort of scenario I tend to calculate the relevant value and pass it to the report in the docmd.openreport's OpenArgs argument.

hth.

--------------------
Warm regards
Bernie
Go to the top of the page
 
mike60smart
post Feb 22 2020, 08:45 AM
Post#7


UtterAccess VIP
Posts: 13,729
Joined: 6-June 05
From: Dunbar,Scotland


Hi Bernie

How would I modify the current OnClick Event to open the Report?

CODE
Private Sub cmdAIM_Click()

10        On Error GoTo cmdAIM_Click_Error

20        DoCmd.OpenReport "rptAIAForPeriod", acViewPreview, "", "", acNormal

          
30        On Error GoTo 0
40        Exit Sub

cmdAIM_Click_Error:

50        MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cmdAIM_Click, line " & Erl & "."

End Sub



--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
orange999
post Feb 22 2020, 09:03 AM
Post#8



Posts: 2,080
Joined: 10-February 08
From: Ottawa, Ont, Canada; West Palm Beach, FL


Mike,

What is latest status?

For clarity, what is the condition to signal you want the report to be visible?


This post has been edited by orange999: Feb 22 2020, 09:08 AM

--------------------
Good luck with your project!
Go to the top of the page
 
pere_de_chipstic...
post Feb 22 2020, 09:24 AM
Post#9


UtterAccess Editor
Posts: 10,594
Joined: 8-November 07
From: South coast, England


Hi Mike

At the end of the open report command add:
OpenArgs:=somevalue

Where somevalue is say "v" for visible and "n" not visible, which you calculate beforehand.
Then in the onload event:
Me.subformname.visible = me.openargs = "v"

hth

--------------------
Warm regards
Bernie
Go to the top of the page
 
mike60smart
post Feb 22 2020, 09:24 AM
Post#10


UtterAccess VIP
Posts: 13,729
Joined: 6-June 05
From: Dunbar,Scotland


Hi orange

When the Report Opens - If txtCheck = 0 then make the Report (rptSummaryforReportBlanksubreport)Visible.

If it is > 0 then show the Other Report (rptSummaryforReportsubreport)Visible.

--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
mike60smart
post Feb 22 2020, 09:36 AM
Post#11


UtterAccess VIP
Posts: 13,729
Joined: 6-June 05
From: Dunbar,Scotland


Hi Bernie

Sorry but I would not have a clue on how to construct what you are suggesting.

Many thanks for the info.

cheers.gif

--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
orange999
post Feb 22 2020, 09:57 AM
Post#12



Posts: 2,080
Joined: 10-February 08
From: Ottawa, Ont, Canada; West Palm Beach, FL


Mike,

There is still some confusion (on my part). In many cases the setup for opening a report is done on a form and then once conditions have been established, the Report is opened with associated properties.

I think you are saying Me.txtCheck is on the Parent report.

I found this via Google. But I'm not sure if you are dealing with a no data issue.
This post has been edited by orange999: Feb 22 2020, 09:57 AM

--------------------
Good luck with your project!
Go to the top of the page
 
mike60smart
post Feb 22 2020, 10:46 AM
Post#13


UtterAccess VIP
Posts: 13,729
Joined: 6-June 05
From: Dunbar,Scotland


Hi Orange

Yes you are right. txtCheck is on the Main Report which opens as expected.

This is checking that a Control on the specific SubReport contains a value greater than Zero.

If there is no value in this specific Control then display a SubReport.

If there is a value greater than Zero then display a different SubReport.


--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
orange999
post Feb 22 2020, 12:10 PM
Post#14



Posts: 2,080
Joined: 10-February 08
From: Ottawa, Ont, Canada; West Palm Beach, FL


Mike ,

Any chance you could post a copy of the database with only a few records --just enough to review/experiment with the issue?

I also found this older UA thread.
This post has been edited by orange999: Feb 22 2020, 12:12 PM

--------------------
Good luck with your project!
Go to the top of the page
 
mike60smart
post Feb 22 2020, 03:38 PM
Post#15


UtterAccess VIP
Posts: 13,729
Joined: 6-June 05
From: Dunbar,Scotland


Hi Bernie


I am trying to apply your suggestion to my Report problem.

On My Command Button I now have the following Code:-

CODE
Private Sub cmdAIM_Click()

10        On Error GoTo cmdAIM_Click_Error
           Dim txtV As Long
20        DoCmd.OpenReport "rptAIAForPeriod", acViewPreview, "", "", acNormal
30        OpenArgs = txtV
          
40        On Error GoTo 0
50        Exit Sub

cmdAIM_Click_Error:

60        MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cmdAIM_Click, line " & Erl & "."

End Sub



The txtV value is the Reference to the SubReport as follows:-

CODE
=IIf([Reports]![rptAIAforPeriod]![rptSummaryforReportsubreport].[Report]![CoNo] Is Null,0,0)
:-

When I run this OnClick Event from my Form to Open the Report I get the following error:-

Attached File  error.PNG ( 2.7K )Number of downloads: 0


When I click OK It opens the Main Report but then also displays this error:-

Attached File  error2.PNG ( 3.56K )Number of downloads: 0


No SubReport is displayed?

On Load Code is:-

CODE
Private Sub Report_Load()

10        On Error GoTo Report_Load_Error

20    If Me.txtV = 0 Then
30    Me.rptSummaryforReportBlanksubreport.Visible = Me.OpenArgs = txtV
40    End If


50        On Error GoTo 0
60        Exit Sub

Report_Load_Error:

70        MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Report_Load, line " & Erl & "."

End Sub

--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
mike60smart
post Feb 22 2020, 03:40 PM
Post#16


UtterAccess VIP
Posts: 13,729
Joined: 6-June 05
From: Dunbar,Scotland


Hi orange

The database is very involved and it would take me quite some time to try and strip it down to just this process.


--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
orange999
post Feb 22 2020, 05:12 PM
Post#17



Posts: 2,080
Joined: 10-February 08
From: Ottawa, Ont, Canada; West Palm Beach, FL


Mike,

I understand. Just can't find anything useful via Google, and haven't worked with the setup you described.

Good luck. I'm sure there are others who'd like to see a solution.

--------------------
Good luck with your project!
Go to the top of the page
 
Jeff B.
post Feb 23 2020, 08:46 AM
Post#18


UtterAccess VIP
Posts: 10,409
Joined: 30-April 10
From: Pacific NorthWet


It sounds like txtCheck is a control on a report. Is the control a "checkbox"? Is the value passed to the report, or are you trying to check a checkbox on a report?

--------------------
Regards

Jeff Boyce
Microsoft Access MVP (2002-2015)

Mention of hardware or software is, in no way, an endorsement thereof. The FTC of the USA made this disclaimer necessary/possible.
Go to the top of the page
 
pere_de_chipstic...
post Feb 23 2020, 09:17 AM
Post#19


UtterAccess Editor
Posts: 10,594
Joined: 8-November 07
From: South coast, England


Hi Mike

In the Open report argument you need to establish if the sub report is to be visible of not before you open the report (e.g.)
CODE
           Dim boltxtV As Boolean
           boltxtV = NZ(DLookup ("txtCheck","SomeTableName", "SomeCriteria",-1) = -1
           DoCmd.OpenReport "rptAIAForPeriod", acViewPreview, "", "", acNormal, OpenArgs:= Cstr(boltxtV)
depending on how txtCheck is determined you may to open a recordset to return its value

Then in your report's onload event
CODE
Me.rptSummaryforReportBlanksubreport.Visible = Cbool(Me.OpenArgs) = 0
(you don't need to check for the value of mtxtV in the reports on load event)

hth

--------------------
Warm regards
Bernie
Go to the top of the page
 
mike60smart
post Feb 23 2020, 10:01 AM
Post#20


UtterAccess VIP
Posts: 13,729
Joined: 6-June 05
From: Dunbar,Scotland


Hi Bernie

Tried this on the OnClick Event and get the following error:-

Attached File  error.PNG ( 22.97K )Number of downloads: 6

--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
2 Pages V  1 2 >


Custom Search


RSSSearch   Top   Lo-Fi    5th April 2020 - 04:48 PM