Solved Use two buttons to print the same report where one prints the detail section ... Freezing my application

I NEVER have spaces in my object names. Enclose those with [] if you insist.

Failing that upload enough to see the issue with instructions on how to replicate.
 
SOLUTION:

Create a form with two buttons and assign the "On Click" code as follows. This drives the OpenArgs to the report (which is only available on an 'on open' event.

Code:
Private Sub PrintButton_RptSObyProductLevel0_Click()

    DoCmd.OpenReport "Rpt - SO by Product2", acViewPreview, , , , "Level0"
   
End Sub

Code:
Private Sub PrintButton_RptSObyProductLevel1_Click()

    DoCmd.OpenReport "Rpt - SO by Product2", acViewPreview, , , , "Level1"
   
End Sub

Then, within the "On Open" of the given Report, enter the following:

Code:
Private Sub Report_Open(Cancel As Integer)

If OpenArgs = "Level0" Then
    Me.Section(0).Visible = False
Else
    Me.Section(0).Visible = True
End If

End Sub
Really puzzled now, as that is what I thought you already had?
 
Really puzzled now, as that is what I thought you already had?
Errors out in the old report, works like a charm in a direct copy of the report with a "2" appended to the name.
And yes, I'm in the process of removing my report name spaces :)
 
So delete the old report, rename the second to that and work from there?
Perhaps corrupted, but in all the time I have use Access, I have never had a corrupted object that I can remember?
Just lucky there, as I would not consider myself lucky really. :)
 
BTW
This drives the OpenArgs to the report (which is only available on an 'on open' event.
is rubbish.
Please see my events.
Code:
Private Sub Report_Load()
Me.Auto_Header0.Caption = Me.OpenArgs & " Report"
End Sub

Same applies to a Form
Code:
Private Sub Form_Load()
' Add which period we are showing to form title label
If Not IsNull(Me.OpenArgs) Then
    Me.lblTitle.Caption = Me.lblTitle.Caption & Me.OpenArgs
    Me.RecordSource = "qry" & Me.OpenArgs
    Me.cmdReport.Visible = True
Else
    Me.cmdReport.Visible = False
End If
DoCmd.GoToRecord acDataForm, Me.Name, acLast
End Sub
 

Users who are viewing this thread

Back
Top Bottom