How to change the report title

G

Gabriel

Hi,
Is there a way to change the report control collection (i.e. report Title)
before opeing the report.
I have a form where users can select filter for the record source (from
radio button) when user click the open report I want the title of the report
refer to the selected radio button from the form.

TIA
Gabriel
 
A

Allen Browne

Not sure if you want to set the Caption of the report:

Private Sub Report_Open(Cancel As Integer)
Select Case Forms!MyForm!MyOptionGroup.Value
Case 1
Me.Caption = "Filtered by option 1"
Case 2
Me.Caption = "Filtered by option 2"
Case Else
Debug.Print Me.Name & "'s Report_Open event didn't handle
option " & Forms!MyForm!MyOptionGroup.Value
End Select
End Sub

or assign a value to a text box on the report, which would need to be done
in the Format event of the (Report Header?) section.


If you are are using Access 2002 or 2003, there is an even easier approach.
Pass the string you wish to display via the OpenArgs of OpenReport, and just
put a text box on the report with a ControlSource of:
=[Report].[OpenArgs]
 
Top