Dynamic Report Title using VBA Forms (1 Viewer)

ccastro24

New member
Local time
Today, 09:32
Joined
Oct 16, 2007
Messages
1
Hi, I'm trying to assign a value to a textbox or label in a report, from a form's VBA in order to change the title of the report every time is opened through the form... so far I have had no luck. What I want to do is to be able for the Title of the report to change depending on the combo box choice in the Form. I would appreciate if somebody could point me in the right direction.

I've tried the following code, the problem is the title will not show in the print preview when opened through vba, but if I open it through MS Access I will show but then the report wont be filtered... Any clues?

Thanks,

C.

VBA Code:

' Assign Month & Year
Month1 = cmbMonth.Value
Year1 = cmbYear.Value

' Create Report Title based on Month and Year combo boxes

strTitle = "Monthly Instance Report: " & Month1 & " " & Year1

' Assign where condition
StrWhere = "Instance.inst_DateComplete Between #" & FirstDate & "# And #" & SecondDate & "#"

'Open Report
DoCmd.OpenReport "Monthly Instance Report", acViewPreview, , StrWhere

'Create Label Title
'Reports![Monthly Instance Report].txtTitle.Value = strTitle
 

RuralGuy

AWF VIP
Local time
Today, 07:32
Joined
Jul 2, 2005
Messages
13,826
Pass your Title in the OpenArgs argument of the OpenReport command and catch the Title on the Open event of the Report and put it in a variable that is the ControlSource for the Title TextBox of the report.
 

meenctg

Learn24bd
Local time
Today, 20:32
Joined
May 8, 2012
Messages
133
Here is a good article about it. I think this will be helpful for your problem.
Dynamic report name
 

Users who are viewing this thread

Top Bottom