Enabling a subreport from form (1 Viewer)

Tupacmoche

Registered User.
Local time
Today, 15:22
Joined
Apr 28, 2008
Messages
291
Hi Report Masters,

I'm using this code to suppress a subreport in a about 10 report. This is my issue. I need the same subreport to run when selected from a different form. How can this be done?

Me.StewardShipKeyMatrix.Visible = False
Me.PageBreak227.Visible = False
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 12:22
Joined
Aug 30, 2003
Messages
36,118
You can pass a value in OpenArgs and use that to determine visibility.
 

Ranman256

Well-known member
Local time
Today, 15:22
Joined
Apr 9, 2015
Messages
4,339
is the code above for the 10 reports? If so, you need do nothing if run from another form.
the subreport should be visible.
or
you can have 2 reports,
save AS and have the subrpt visible, and open it from the other form.
or
the query in the report could look at a text box on the form.
when the report opens , turns the subform on/off depending on the form code.
the query would open a 3rd form to hold the code

docmd.openForm "fCode"
forms!fCode!txtCode = "A"
docmd.OpenReport "myReport"

the query pulls data AND the code:
select *, forms!fCode!txtBox from table


Code:
Private Sub ReportHeader_Print(Cancel As Integer, PrintCount As Integer)
  subRpt.visible = me.txtBox = "A"
End Sub
 

Tupacmoche

Registered User.
Local time
Today, 15:22
Joined
Apr 28, 2008
Messages
291
I found a solution as follows:

I created a function:

Public Function DecUser()
Dim UserC As Boolean
UserC = False
If GetCurrUser = "RS" Or _
GetCurrUser = "EP" Or _
GetCurrUser = "AR" Or _
GetCurrUser = "TA" Or _
GetCurrUser = "EG" Or _
GetCurrUser = "ML" Or _
GetCurrUser = "CB" Then UserC = True
If UserC = False Then
Else
End If
DecUser = UserC
End Function

Then, I called the function such:

Me.StewardShipKeyMatrix.Visible = DecUser()
Me.PageBreak227.Visible = DecUser()

I call this code from the Details on format event.

Works well.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 12:22
Joined
Aug 30, 2003
Messages
36,118
Ouch. What is GetCurrUser? If it's a function, I'd just call it once. You can probably put those in a table for better maintainability and just do a lookup with the function. You mentioned forms in the first post, this looks more like users.
 

Gasman

Enthusiastic Amateur
Local time
Today, 19:22
Joined
Sep 21, 2011
Messages
14,046
I found a solution as follows:

I created a function:

Public Function DecUser()
Dim UserC As Boolean
UserC = False
If GetCurrUser = "RS" Or _
GetCurrUser = "EP" Or _
GetCurrUser = "AR" Or _
GetCurrUser = "TA" Or _
GetCurrUser = "EG" Or _
GetCurrUser = "ML" Or _
GetCurrUser = "CB" Then UserC = True
If UserC = False Then
Else
End If
DecUser = UserC
End Function

Then, I called the function such:

Me.StewardShipKeyMatrix.Visible = DecUser()
Me.PageBreak227.Visible = DecUser()

I call this code from the Details on format event.

Works well.

What does this do?
Code:
If UserC = False Then
Else
End If
 

Tupacmoche

Registered User.
Local time
Today, 15:22
Joined
Apr 28, 2008
Messages
291
Nothing it was just recycled code so, I did not change it.
 

Users who are viewing this thread

Top Bottom