View Full Version : Page copies to show on report ( not page number)


Ziggy1
07-02-2010, 07:44 AM
Hi

I'm using the Openreport method, and using a text box to control copies, how can I get the copy number to show on the printout for each page printed?

HiTechCoach
07-02-2010, 08:36 AM
Hi

I'm using the Openreport method, and using a text box to control copies, how can I get the copy number to show on the printout for each page printed?

I assume that you are using a loop to print he report multiple times. If this is correct, how I do it is to pass the copy number to the report using the OpenArgs parameter of the Docmd.OpenReport method. In the report you can use Me.OpenArgs to get the copy number passed.

Hope this helps ...

Ziggy1
07-02-2010, 08:39 AM
I don't need a loop, this is what I am using...

Private Sub cmdPrintLabel_Click()


Dim stDocName As String


stDocName = "rptShippingLabel2"
DoCmd.OpenReport stDocName, acViewPreview
DoCmd.PrintOut acSelection, , , acLow, Me.txtCopies
DoCmd.Close


End Sub

Ziggy1
07-02-2010, 08:44 AM
I need an event that fires everytime the page prints a copy... I thought ON print would work, but I don't see it firing everytime

Ziggy1
07-02-2010, 09:06 AM
I guess I should do away with the "DoCmd.PrintOut" and use the open report alone with acNormal and use a loop from my copies text box...like you thought I was doing.

HiTechCoach
07-02-2010, 09:16 AM
I need an event that fires everytime the page prints a copy... I thought ON print would work, but I don't see it firing everytime

The .Printout with multiple copies tells the printer spooler to send the print job multiple times to the printer. Access on prints/renders the report once.

That is why I use the loop to generate/print the report multiple times with Access. This will allow Access to print a different copy number each time the report is generated.

DCrake
07-02-2010, 09:42 AM
The only issue with looping is that Access opens the print dialog box for each loop. This is only once when using ncopies via the print spooler.

Ziggy1
07-02-2010, 09:46 AM
The only issue with looping is that Access opens the print dialog box for each loop. This is only once when using ncopies via the print spooler.

I don't get it everytime

Ziggy1
07-02-2010, 09:49 AM
ok, I'm having trouble passing the OpenArg...


Private Sub cmdPrintShipLabel_Click()
On Error GoTo Err_cmdPrintShipLabel_Click

Dim stDocName As String
Dim copy1 As Integer

copy1 = Me.txtCopies


For copy1 = 1 To Me.txtCopies

stDocName = "rptShippingLabel2"
DoCmd.OpenReport stDocName, acNormal, , , , copy1

Next copy1


Exit_cmdPrintShipLabel_Click:
Exit Sub

Err_cmdPrintShipLabel_Click:
MsgBox Err.Description
Resume Exit_cmdPrintShipLabel_Click

End Sub



Private Sub Report_Open(Cancel As Integer)

Dim strOpenArg As String

strOpenArg = Me.OpenArgs

Me.txtCopy = strOpenArg


End Sub


in the report open the openarg is null?

vbaInet
07-02-2010, 09:57 AM
See if this example I once did for someone on here helps. May not be what you're after but see attached.

DCrake
07-02-2010, 09:59 AM
Define a public variable in a standard module

Public RptCopyNo As Integer


Dim stDocName As String
Dim I As Integer
stDocName = "rptShippingLabel2"

For I = 1 To Me.txtCopies
RptCopyNo = I
DoCmd.OpenReport stDocName, acNormal
Next

Then in the report

Private Sub Report_Open(Cancel As Integer)

Me.txtCopy = RptCopyNo

End Sub

Ziggy1
07-02-2010, 11:12 AM
Define a public variable in a standard module

[Then in the report

Private Sub Report_Open(Cancel As Integer)

Me.txtCopy = RptCopyNo

End Sub


I understand all this, but when I try to assign a value to the text box I get an error saying "You can't assign value to this object"

I even tried with a hardcoded value?

Ziggy1
07-02-2010, 11:26 AM
ok I got it, should have put into the format event

Thanks for the help guys

DCrake
07-02-2010, 12:21 PM
Is/Was me.TxtCopy a label? if so you should have said it like this

Me.TxtCopy.Caption = RptCopyNo

Ziggy1
07-02-2010, 12:32 PM
Is/Was me.TxtCopy a label? if so you should have said it like this

Me.TxtCopy.Caption = RptCopyNo

it was a text box, but I don't think the control is available to pass data in the open event... possibly LOAD, either way the format event works.

I was making a shipping label, in case anyone wonders what this is for.

DCrake
07-02-2010, 12:36 PM
You needed to put it in the header section of the report or whatever section or the report the copy number was being displayed.