User controls report copies

  • Thread starter Thread starter gary
  • Start date Start date
G

gary

I have the following code on a Print button:

DoCmd.OpenReport stDocName, acViewPreview
DoCmd.PrintOut
DoCmd.close acReport, stDocName, acSaveNo

I also have a field where I want the user to input the
number of copies they want.
How do I then make the code print the number of copies
that is shown in field "copiestoprint"

Thanks very much.

I feel like this is simple but I have been stumped.

Gary.
 
Try this: -

Dim N,LoopCount As Integer
'Will Not Print if number of copies is not specified
if me.copiestoprint=0 then exit sub
if isnull (me.copiestoprint) then exit sub
'Sets the number of copies to be printed
LoopCount = me.copiestoprint
For N 1 to LoopCount
DoCmd.OpenReport stDocName, acViewNormal
Next N

Note that I've gone with "acViewNormal" rather
than "acViewPreview", this will save on CPU Time and it
will not annoy the user with a flickering screen.

HTH


Tony C.
 
From Help

DoCmd.PrintOut [printrange][, pagefrom, pageto][, printquality][, copies][,
collatecopies]
 
Back
Top