Go Back   Access World Forums > Microsoft Access Discussion > Reports

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 11-15-2018, 09:54 AM   #1
Tupacmoche
Newly Registered User
 
Join Date: Apr 2008
Posts: 201
Thanks: 56
Thanked 4 Times in 4 Posts
Tupacmoche is on a distinguished road
Enabling a subreport from form

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

Tupacmoche is offline   Reply With Quote
Old 11-15-2018, 10:32 AM   #2
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 32,166
Thanks: 10
Thanked 3,887 Times in 3,830 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: Enabling a subreport from form

You can pass a value in OpenArgs and use that to determine visibility.
__________________
Paul
Microsoft Access MVP

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is offline   Reply With Quote
The Following User Says Thank You to pbaldy For This Useful Post:
Tupacmoche (11-16-2018)
Old 11-15-2018, 10:35 AM   #3
Ranman256
Newly Registered User
 
Join Date: Apr 2015
Location: KY,USA
Posts: 3,157
Thanks: 0
Thanked 690 Times in 675 Posts
Ranman256 will become famous soon enough Ranman256 will become famous soon enough
Re: Enabling a subreport from form

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

Ranman256 is offline   Reply With Quote
Old 11-16-2018, 01:22 PM   #4
Tupacmoche
Newly Registered User
 
Join Date: Apr 2008
Posts: 201
Thanks: 56
Thanked 4 Times in 4 Posts
Tupacmoche is on a distinguished road
Re: Enabling a subreport from form

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.
Tupacmoche is offline   Reply With Quote
Old 11-16-2018, 01:27 PM   #5
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 32,166
Thanks: 10
Thanked 3,887 Times in 3,830 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: Enabling a subreport from form

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.
__________________
Paul
Microsoft Access MVP

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is offline   Reply With Quote
Old 11-16-2018, 01:57 PM   #6
Gasman
Access newbie
 
Join Date: Sep 2011
Location: Swansea, South Wales,UK
Posts: 2,701
Thanks: 317
Thanked 425 Times in 410 Posts
Gasman has a spectacular aura about Gasman has a spectacular aura about
Re: Enabling a subreport from form

Quote:
Originally Posted by Tupacmoche View Post
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
__________________
Access novice. Sometimes trying to give something back.
Access 2007
Gasman is offline   Reply With Quote
Old 11-16-2018, 03:57 PM   #7
Tupacmoche
Newly Registered User
 
Join Date: Apr 2008
Posts: 201
Thanks: 56
Thanked 4 Times in 4 Posts
Tupacmoche is on a distinguished road
Re: Enabling a subreport from form

Nothing it was just recycled code so, I did not change it.


Tupacmoche is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Enabling a form control peted Forms 6 02-01-2008 05:38 AM
Need help with enabling a sub form SheaLee Modules & VBA 1 08-23-2006 08:08 AM
Enabling SubForm of a form ! totolkhan Forms 1 11-26-2005 04:35 PM
Enabling form fields Del_Piero_3 Forms 13 07-23-2004 05:35 AM
Enabling of Buttons on a form DazedandMuddled Forms 5 04-13-2004 07:25 AM




All times are GMT -8. The time now is 08:57 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World