G
Guest
Does anyone know how I can pass a variable from a subroutine to an unbound field on a report? The subroutine is triggered by the on click event of a control button on a form.
This is my code so far where I have attempted to declare a variable within a module.
Firstly, for the control button on the form:
Private Sub Preview_Click()
ReportName = "Countsheet"
StoreClass = Me.Frame13
VarToReport
DoCmd.OpenReport _
ReportName:=ReportName, _
View:=acViewPreview, _
WhereCondition:="SC<=" & Me.Frame13 & "AND Department='" & Me.Frame28 & "'"
End Sub
Secondly, for a module entitled "Variables":
Function VarToReport()
VarToReport = StoreClass
End Function
The control source for the text box on the report has been set to VarToReport, however, it merely produces an "Enter Parameter Value" dialog box for VarToReport. (Due to my lack of experience, I guess the answer may well be something quite simple...!).
This is my code so far where I have attempted to declare a variable within a module.
Firstly, for the control button on the form:
Private Sub Preview_Click()
ReportName = "Countsheet"
StoreClass = Me.Frame13
VarToReport
DoCmd.OpenReport _
ReportName:=ReportName, _
View:=acViewPreview, _
WhereCondition:="SC<=" & Me.Frame13 & "AND Department='" & Me.Frame28 & "'"
End Sub
Secondly, for a module entitled "Variables":
Function VarToReport()
VarToReport = StoreClass
End Function
The control source for the text box on the report has been set to VarToReport, however, it merely produces an "Enter Parameter Value" dialog box for VarToReport. (Due to my lack of experience, I guess the answer may well be something quite simple...!).