'======================== this code in the Form ======================
Option Compare Database
Option Explicit
Private mstrRptHeaderLabel As String
Private mstrRptSQL As String
'<<<<<<<<<<<<<< --- PROPERTY STATEMENTS --- >>>>>>>>>
Property Let prpRptHeaderLabel(strHeader As String)
mstrRptHeaderLabel = strHeader
End Property 'prpRptHeaderLabel Let
Property Get prpRptHeaderLabel() As String
prpRptHeaderLabel = mstrRptHeaderLabel
End Property 'prpRptHeaderLabel Get
Property Get prpRptSQL() As String
prpRptSQL = mstrRptSQL
End Property 'prpRptSQL Get
Property Let prpRptSQL(strHeader As String)
mstrRptSQL = strHeader
End Property 'prpRptSQL Let
Private Sub btnOpenRport_Click()
Me.prpRptSQL = "SELECT ID, T1, T2, T3, T4 FROM Table1 WHERE (((T3)='ww'))"
Me.prpRptHeaderLabel = "REPORT HEADER FROM FORM"
Dim strRptName As String
strRptName = "rptTable1"
DoCmd.OpenReport strRptName, acViewReport, , , , Me.Name
With Reports(strRptName)
.Caption = "I CAN CHANGE THE CAPTION"
End With
End Sub
'======================== this code in the Form ======================
'======================== this code in the Report ======================
Option Compare Database
Option Explicit
Private Sub Report_Open(Cancel As Integer)
If Len(Me.OpenArgs) > 0 Then
With Forms(Me.OpenArgs)
Me.RecordSource = .prpRptSQL
Me.lblRptHeader.Caption = .prpRptHeaderLabel
Me.lblShowSQL.Caption = .prpRptSQL
End With
End If
End Sub
'======================== this code in the Report ======================