D
dch3
I have several module-level variables in a report that I'm designing. The
variables will be set via a routine that extracts the values from the
..OpenArgs property. I want to smoothly and gracefully extract the values and
set the variables in such a way that I can reuse the technique on any form
and on any report.
What I need to know is how you can pass the NAME of variable into a sub as a
string and then using the string set the variable that the string refers to?
The code's listed below. Report_Open works like a charm - no issues. Its the
setParameterVariable() sub that's not working. I was thinking Eval() but it
doesn't work.
The idea is that the .OpenArgs will contain a string where each
variable/value pair is delimited with a ";" and then subdelimited with a "="
as in
"mPrintLoadListHeaderInformation=True;mPrintDetail=True;mPrintFooter=True"
Option Compare Database
Option Explicit
Dim aOpenParameters()
Dim mPrintLoadListHeaderInformation As Boolean
Dim intNumberOfParameters As Integer
Private Sub Report_Open(Cancel As Integer)
'Break the string using ";" as the delimiter
Dim aOpenArgs
'Break the substrings using "=" as the delimiter
Dim aOpenArgsDetail
Dim i As Integer
aOpenArgs = Split(Me.OpenArgs, ";")
intNumberOfParameters = charactersInString(";", Me.OpenArgs)
If intNumberOfParameters > 0 Then
ReDim aOpenParameters(intNumberOfParameters, 2)
For i = 0 To intNumberOfParameters - 1
aOpenArgsDetail = Split(aOpenArgs(i), "=")
aOpenParameters(i, 0) = aOpenArgsDetail(0)
aOpenParameters(i, 1) = aOpenArgsDetail(1)
Next i
End If
Call setParameterVariable("mPrintLoadListHeaderInformation")
End Sub
Sub setParameterVariable(strParameter)
Dim i As Integer
For i = 0 To intNumberOfParameters
If aOpenParameters(i, 0) = strParameter Then
Eval(strParameter) = aOpenParameters(i, 1)
End If
Next i
End Sub
variables will be set via a routine that extracts the values from the
..OpenArgs property. I want to smoothly and gracefully extract the values and
set the variables in such a way that I can reuse the technique on any form
and on any report.
What I need to know is how you can pass the NAME of variable into a sub as a
string and then using the string set the variable that the string refers to?
The code's listed below. Report_Open works like a charm - no issues. Its the
setParameterVariable() sub that's not working. I was thinking Eval() but it
doesn't work.
The idea is that the .OpenArgs will contain a string where each
variable/value pair is delimited with a ";" and then subdelimited with a "="
as in
"mPrintLoadListHeaderInformation=True;mPrintDetail=True;mPrintFooter=True"
Option Compare Database
Option Explicit
Dim aOpenParameters()
Dim mPrintLoadListHeaderInformation As Boolean
Dim intNumberOfParameters As Integer
Private Sub Report_Open(Cancel As Integer)
'Break the string using ";" as the delimiter
Dim aOpenArgs
'Break the substrings using "=" as the delimiter
Dim aOpenArgsDetail
Dim i As Integer
aOpenArgs = Split(Me.OpenArgs, ";")
intNumberOfParameters = charactersInString(";", Me.OpenArgs)
If intNumberOfParameters > 0 Then
ReDim aOpenParameters(intNumberOfParameters, 2)
For i = 0 To intNumberOfParameters - 1
aOpenArgsDetail = Split(aOpenArgs(i), "=")
aOpenParameters(i, 0) = aOpenArgsDetail(0)
aOpenParameters(i, 1) = aOpenArgsDetail(1)
Next i
End If
Call setParameterVariable("mPrintLoadListHeaderInformation")
End Sub
Sub setParameterVariable(strParameter)
Dim i As Integer
For i = 0 To intNumberOfParameters
If aOpenParameters(i, 0) = strParameter Then
Eval(strParameter) = aOpenParameters(i, 1)
End If
Next i
End Sub