
Global Variable passed to Parameter
I have a report, which is based on a query. The query has an open
Parameter [papernum] which requires inputting on opening of the
report. (i.e. Enter Parameter Value box)
The report needs to be printed many times, for many different values
of [papernum], so I have put a loop in a vb module to pass an
incrementing number to [papernum] as a global variable.
But it doesn't work :-(
When the openreport runs, it still asks me to 'Enter Parameter Value'
for papernum, and I have not got a clue why. Could someone please
point out my (almost certainly trivial) error. Thanks
Code is as follows:
Option Compare Database
Global papernum As Integer
_________________________
Function PrintReps()
For I = 1 To 200
papernum = I
DoCmd.OpenReport "ReportForPrinting", acViewPreview
' note, acViewPreview will be changed to acViewNormal when code works
MsgBox papernum
' this is to check the variable is looping correctly...it is.
Next I
End Function