Setting the heading on a report from a combi field on a form

MarionD

Registered User.
Local time
Today, 17:56
Joined
Oct 10, 2000
Messages
425
Hi Guys, Sorry - I know this should be easy but it's just not working for me.
I have a form with a combi field - 3 Columns - ID;Description; Startdate
I click a button to open a report and want to set the heading on the Report (textfield) to the description & startdate on the form (column2 and 3)
eg. "Street Festival" & " starting on " & "31 May 2025"
_______ Column2_______________________________Column3

Thanks for any help!
 
Try something like:
Code:
=Forms!FormName.ComboName.Column(1) & etc.
Sent from phone...
 
This presumes the form's button's code uses vba to open that report and that you are using a label on the report to hold that composed text you want to place on it. If not, you need to tell us how the form is opening exactly.

After the DoCmd.OpenReport you will need code similar to the below:

Code:
' Form opens above, then the caption is set below

Dim str_Caption As String
str_Caption = Forms!YourFormNameHere!Description & " starting on " &  Forms!YourFormNameHere!Startdate
Reports!YourReportNameHere!CaptionLabelNameHere.Caption = str_Caption

Again, this presumes you have VBA and are using DoCmd.OpenReport to open the report. If not, then you have bigger issues because the code I just gave you only changes the label, it does not implement the criteria to the data on the report
 
for labels, you need to put a code on the Report's Load event:
Code:
Private Sub Report_Load()
Me!yourLabelName.Caption = Forms!YourFormName!Comboname(2) & " starting on " & Forms!YourFormName!Comboname(3)
End Sub
 
Thank you all so very much! Got it working now with all your advice!
 
This is why openargs exists. I know people normally use it when opening forms but it is also part of the OpenReport parameters as well!
 
For future reference, you can have the source query for your combo do the work for you.
Field 1 could be your ID.
Field 2 could be ReportTitle: [Description] & " starting on " & [StartDate]

Doing it this way helps when you want to use the same source multiple places AND you want to use the same formatting.
 

Users who are viewing this thread

Back
Top Bottom