Question : Change label caption in report header

I have a report that I open with a button on a form that holds the criteria for the query behind the report. When they click the button to view the report I added code asking them if this is the Final Summary Yes or No

Yes
Caption = Final Summary From Main Office

No
Caption = Running Total Summary From Main Office

Heres the code that I tried using.

Private Sub cmdTotalRec_Click()
On Error GoTo Err_cmdTotalRec_Click
    Dim stDocName As String
    Dim stLinkCriteria As String
    Dim intResponse As Integer
    Dim stElection As String
    Dim stElectDate As String
    stDocName = "rptViewReceivedByEvent"
   
    stElection = Me.cboElectionName.Value
    stElectDate = Me.txtElectionDate.Value
   
    intResponse = MsgBox("Is this the final Summary Total for ?" & stElection & " " & stElecDate, _
                 vbYesNo + vbQuestion, "Cancel Scan")
    If intResponse = vbYes Then
    Reports!stDocName!lblReportTitle.Caption = "Final Total Summary Received From Downtown"
    Else
    Reports!stDocName!lblReportTitle.Caption = "View Running Total Summary Received From Downtown"
   
    End If
   
    DoCmd.OpenReport stDocName, acPreview

Exit_cmdTotalRec_Click:
    Exit Sub

Err_cmdTotalRec_Click:
    MsgBox Err.Description
    Resume Exit_cmdTotalRec_Click
   
End Sub

Answer : Change label caption in report header

Hi redcurl40,

Try passing it through OpenArgs

   intResponse = MsgBox("Is this the final Summary Total for ?" & stElection & " " & stElecDate, _
                 vbYesNo + vbQuestion, "Cancel Scan")
    If intResponse = vbYes Then
        DoCmd.OpenReport stDocName, acPreview , , , acWindowNormal, "Final Total Summary Received From Downtown"
    Else
        DoCmd.OpenReport stDocName, acPreview , , , acWindowNormal, "View Running Total Summary Received From Downtown"
   
    End If

Then in your Report

Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As Integer)
    Me.lableName.captopn = Me.OpenArgs
End Sub


Dave :-)
Random Solutions  
 
programming4us programming4us