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
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