R
rwfreeman
Access 2003. I'm trying to pass values for two variables to a report
from a form but the controls on the report are giving me "#Name?"
errors wherever the passed variables are used.
Here's the code on the form
Private Sub cmdPreviewClaim_Click()
Dim strOpenArgs As String
strOpenArgs = Forms!frmMain.Form.cboxPlanYear & "|" & Forms!
frmMain.Form.currSetAside
DoCmd.OpenReport "rptClaim", acViewPreview, , , , strOpenArgs
End Sub
Here's the Open event of the report (ParseText() is a module level
function to parse strings with a "|" delimiter). The variables are
DIMmed as public variables in the Declarations section of the report
code.
Private Sub Report_Open(Cancel As Integer)
If Not IsNull(Me.OpenArgs) Then
intCAFEPlanYear = ParseText(Me.OpenArgs, 0)
currCAFESetAside = ParseText(Me.OpenArgs, 1)
End If
End Sub
There aren't any name conflicts between controls in the report and
names for the passed variables. It doesn't seem to matter where
(module vs. report) that the variables are DIMmed. If Access pops up
the window that asks for values for these variables and one enters
values for them, the report does what it's supposed to do. But if
values for the variables come from code, the report controls (which
are text boxes with experssions as the ControlSource) show #Name?
errors.
It's gotta be simple but I'm stumped.
Richard
from a form but the controls on the report are giving me "#Name?"
errors wherever the passed variables are used.
Here's the code on the form
Private Sub cmdPreviewClaim_Click()
Dim strOpenArgs As String
strOpenArgs = Forms!frmMain.Form.cboxPlanYear & "|" & Forms!
frmMain.Form.currSetAside
DoCmd.OpenReport "rptClaim", acViewPreview, , , , strOpenArgs
End Sub
Here's the Open event of the report (ParseText() is a module level
function to parse strings with a "|" delimiter). The variables are
DIMmed as public variables in the Declarations section of the report
code.
Private Sub Report_Open(Cancel As Integer)
If Not IsNull(Me.OpenArgs) Then
intCAFEPlanYear = ParseText(Me.OpenArgs, 0)
currCAFESetAside = ParseText(Me.OpenArgs, 1)
End If
End Sub
There aren't any name conflicts between controls in the report and
names for the passed variables. It doesn't seem to matter where
(module vs. report) that the variables are DIMmed. If Access pops up
the window that asks for values for these variables and one enters
values for them, the report does what it's supposed to do. But if
values for the variables come from code, the report controls (which
are text boxes with experssions as the ControlSource) show #Name?
errors.
It's gotta be simple but I'm stumped.
Richard