Page copies to show on report ( not page number) (1 Viewer)

Ziggy1

Registered User.
Local time
Today, 19:14
Joined
Feb 6, 2002
Messages
462
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

Well-known member
Local time
Today, 13:14
Joined
Mar 6, 2006
Messages
4,357
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

Registered User.
Local time
Today, 19:14
Joined
Feb 6, 2002
Messages
462
I don't need a loop, this is what I am using...

Code:
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

Registered User.
Local time
Today, 19:14
Joined
Feb 6, 2002
Messages
462
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

Registered User.
Local time
Today, 19:14
Joined
Feb 6, 2002
Messages
462
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

Well-known member
Local time
Today, 13:14
Joined
Mar 6, 2006
Messages
4,357
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

Remembered
Local time
Today, 19:14
Joined
Jun 8, 2005
Messages
8,626
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

Registered User.
Local time
Today, 19:14
Joined
Feb 6, 2002
Messages
462
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

Registered User.
Local time
Today, 19:14
Joined
Feb 6, 2002
Messages
462
ok, I'm having trouble passing the OpenArg...


Code:
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

AWF VIP
Local time
Today, 19:14
Joined
Jan 22, 2010
Messages
26,374
See if this example I once did for someone on here helps. May not be what you're after but see attached.
 

Attachments

  • PrintCopies.mdb
    228 KB · Views: 98

DCrake

Remembered
Local time
Today, 19:14
Joined
Jun 8, 2005
Messages
8,626
Define a public variable in a standard module

Code:
Public RptCopyNo As Integer

Code:
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

Code:
Private Sub Report_Open(Cancel As Integer)

      Me.txtCopy = RptCopyNo

End Sub
 

Ziggy1

Registered User.
Local time
Today, 19:14
Joined
Feb 6, 2002
Messages
462
Define a public variable in a standard module

[Then in the report

Code:
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

Registered User.
Local time
Today, 19:14
Joined
Feb 6, 2002
Messages
462
ok I got it, should have put into the format event

Thanks for the help guys
 

DCrake

Remembered
Local time
Today, 19:14
Joined
Jun 8, 2005
Messages
8,626
Is/Was me.TxtCopy a label? if so you should have said it like this

Me.TxtCopy.Caption = RptCopyNo
 

Ziggy1

Registered User.
Local time
Today, 19:14
Joined
Feb 6, 2002
Messages
462
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

Remembered
Local time
Today, 19:14
Joined
Jun 8, 2005
Messages
8,626
You needed to put it in the header section of the report or whatever section or the report the copy number was being displayed.
 

Users who are viewing this thread

Top Bottom