Hide detail section

G

Guest

I have a report with a summary header and a detail section. I don't want to
have to create two reports (one that shows just the summary data and one that
shows both summary and detail data). Is there a way to use the same report
accessible by two buttons on my form that when clicking the first button, the
summary data displays and when clicking the second button, both the summary
and detail data displays?
 
G

Guest

You cab use the OpenArgs of the open report command line
From the button you want to display the sub write

Docmd.OpenReport "ReportName" , , , , ,True

And from the other
Docmd.OpenReport "ReportName" , , , , ,False

On the OnOpen event of the form write the code

Me.[Detail Sub].Visible = Me.OpenArgs
 
A

Allen Browne

How about a check box on your form to indicate whether the detail is shown
or not?

You could then use the Open event of the report to see if the form is open,
and if so whether this box is checked.

This kind of thing:

Private Sub Report_Open(Cancel As Integer)
Const strcForm As String = "frmReport"
If CurrentProject.AllForms(strcForm).IsLoaded Then
Me.Section(acDetail).Visible = _
Nz(Forms(strcForm)!chkShowDetail.Value, False)
End If
End Sub
 
G

Guest

I am getting an error when I code the OnOpen of the form:

Me.[Detail Sub].Visible = Me.OpenArgs

Should I be substituting the Sub with the name of the control
'DispSum_Click()'

i.e. Me.[Detail DispSum_Click()].Visible = Me.OpenArgs

Ofer Cohen said:
You cab use the OpenArgs of the open report command line
From the button you want to display the sub write

Docmd.OpenReport "ReportName" , , , , ,True

And from the other
Docmd.OpenReport "ReportName" , , , , ,False

On the OnOpen event of the form write the code

Me.[Detail Sub].Visible = Me.OpenArgs


--
Good Luck
BS"D


Ernie Sersen said:
I have a report with a summary header and a detail section. I don't want to
have to create two reports (one that shows just the summary data and one that
shows both summary and detail data). Is there a way to use the same report
accessible by two buttons on my form that when clicking the first button, the
summary data displays and when clicking the second button, both the summary
and detail data displays?
 
A

Allen Browne

I think Ofer intended to write that the line of code goes in the Open event
of the *report*.

You will need Access 2002 or 2003 to get this OpenArgs approach to work.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Ernie Sersen said:
I am getting an error when I code the OnOpen of the form:

Me.[Detail Sub].Visible = Me.OpenArgs

Should I be substituting the Sub with the name of the control
'DispSum_Click()'

i.e. Me.[Detail DispSum_Click()].Visible = Me.OpenArgs

Ofer Cohen said:
You cab use the OpenArgs of the open report command line
From the button you want to display the sub write

Docmd.OpenReport "ReportName" , , , , ,True

And from the other
Docmd.OpenReport "ReportName" , , , , ,False

On the OnOpen event of the form write the code

Me.[Detail Sub].Visible = Me.OpenArgs


--
Good Luck
BS"D


Ernie Sersen said:
I have a report with a summary header and a detail section. I don't
want to
have to create two reports (one that shows just the summary data and
one that
shows both summary and detail data). Is there a way to use the same
report
accessible by two buttons on my form that when clicking the first
button, the
summary data displays and when clicking the second button, both the
summary
and detail data displays?
 
G

Guest

I added the statement Me.[Detail Sub].Visible = Me.OpenArgs into the On Open
statement of the report and I get the error message "Run-time error '2465':
Microsoft Office Access can't find the field '|' referred to in your
expression. Again, should I be substituting the name of the Sub in this
statement (i.e. Control name = DispSum_Click() ?

In your other post, Allen, I'm not sure what I have to substitute in your
code. Form name is InvForm, Check box on form is InvSumCheck, and Report is
InvReport. Can you help me fill in the blanks?

Allen Browne said:
I think Ofer intended to write that the line of code goes in the Open event
of the *report*.

You will need Access 2002 or 2003 to get this OpenArgs approach to work.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Ernie Sersen said:
I am getting an error when I code the OnOpen of the form:

Me.[Detail Sub].Visible = Me.OpenArgs

Should I be substituting the Sub with the name of the control
'DispSum_Click()'

i.e. Me.[Detail DispSum_Click()].Visible = Me.OpenArgs

Ofer Cohen said:
You cab use the OpenArgs of the open report command line
From the button you want to display the sub write

Docmd.OpenReport "ReportName" , , , , ,True

And from the other
Docmd.OpenReport "ReportName" , , , , ,False

On the OnOpen event of the form write the code

Me.[Detail Sub].Visible = Me.OpenArgs


--
Good Luck
BS"D


:

I have a report with a summary header and a detail section. I don't
want to
have to create two reports (one that shows just the summary data and
one that
shows both summary and detail data). Is there a way to use the same
report
accessible by two buttons on my form that when clicking the first
button, the
summary data displays and when clicking the second button, both the
summary
and detail data displays?
 
A

Allen Browne

Ernie, I posted this in a parallel reply:

Private Sub Report_Open(Cancel As Integer)
Const strcForm As String = "frmReport"
If CurrentProject.AllForms(strcForm).IsLoaded Then
Me.Section(acDetail).Visible = _
Nz(Forms(strcForm)!chkShowDetail.Value, False)
End If
End Sub

Replace "frmReport" with the name of your form, and chkShowDetail with the
name of your checkbox.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Ernie Sersen said:
I added the statement Me.[Detail Sub].Visible = Me.OpenArgs into the On
Open
statement of the report and I get the error message "Run-time error
'2465':
Microsoft Office Access can't find the field '|' referred to in your
expression. Again, should I be substituting the name of the Sub in this
statement (i.e. Control name = DispSum_Click() ?

In your other post, Allen, I'm not sure what I have to substitute in your
code. Form name is InvForm, Check box on form is InvSumCheck, and Report
is
InvReport. Can you help me fill in the blanks?

Allen Browne said:
I think Ofer intended to write that the line of code goes in the Open
event
of the *report*.

You will need Access 2002 or 2003 to get this OpenArgs approach to work.

Ernie Sersen said:
I am getting an error when I code the OnOpen of the form:

Me.[Detail Sub].Visible = Me.OpenArgs

Should I be substituting the Sub with the name of the control
'DispSum_Click()'

i.e. Me.[Detail DispSum_Click()].Visible = Me.OpenArgs

:

You cab use the OpenArgs of the open report command line
From the button you want to display the sub write

Docmd.OpenReport "ReportName" , , , , ,True

And from the other
Docmd.OpenReport "ReportName" , , , , ,False

On the OnOpen event of the form write the code

Me.[Detail Sub].Visible = Me.OpenArgs


--
Good Luck
BS"D


:

I have a report with a summary header and a detail section. I don't
want to
have to create two reports (one that shows just the summary data and
one that
shows both summary and detail data). Is there a way to use the same
report
accessible by two buttons on my form that when clicking the first
button, the
summary data displays and when clicking the second button, both the
summary
and detail data displays?
 
G

Guest

It worked! Thanks, Allen.

Allen Browne said:
Ernie, I posted this in a parallel reply:

Private Sub Report_Open(Cancel As Integer)
Const strcForm As String = "frmReport"
If CurrentProject.AllForms(strcForm).IsLoaded Then
Me.Section(acDetail).Visible = _
Nz(Forms(strcForm)!chkShowDetail.Value, False)
End If
End Sub

Replace "frmReport" with the name of your form, and chkShowDetail with the
name of your checkbox.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Ernie Sersen said:
I added the statement Me.[Detail Sub].Visible = Me.OpenArgs into the On
Open
statement of the report and I get the error message "Run-time error
'2465':
Microsoft Office Access can't find the field '|' referred to in your
expression. Again, should I be substituting the name of the Sub in this
statement (i.e. Control name = DispSum_Click() ?

In your other post, Allen, I'm not sure what I have to substitute in your
code. Form name is InvForm, Check box on form is InvSumCheck, and Report
is
InvReport. Can you help me fill in the blanks?

Allen Browne said:
I think Ofer intended to write that the line of code goes in the Open
event
of the *report*.

You will need Access 2002 or 2003 to get this OpenArgs approach to work.

I am getting an error when I code the OnOpen of the form:

Me.[Detail Sub].Visible = Me.OpenArgs

Should I be substituting the Sub with the name of the control
'DispSum_Click()'

i.e. Me.[Detail DispSum_Click()].Visible = Me.OpenArgs

:

You cab use the OpenArgs of the open report command line
From the button you want to display the sub write

Docmd.OpenReport "ReportName" , , , , ,True

And from the other
Docmd.OpenReport "ReportName" , , , , ,False

On the OnOpen event of the form write the code

Me.[Detail Sub].Visible = Me.OpenArgs


--
Good Luck
BS"D


:

I have a report with a summary header and a detail section. I don't
want to
have to create two reports (one that shows just the summary data and
one that
shows both summary and detail data). Is there a way to use the same
report
accessible by two buttons on my form that when clicking the first
button, the
summary data displays and when clicking the second button, both the
summary
and detail data displays?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top