Print Copies of report based upon value

NPUser

Registered User.
Local time
Today, 01:20
Joined
Jul 25, 2004
Messages
55
Hello need some advise.

I have following on the table:

ID Name CopiesPrint
1 Jim 10
23 Sam 2
56 John 3


Report Source Query:
select id, name, copiesPrint from table1

I would like to print 10 copes of id 1 Jim and 2 copies of id 23 Sam and so on.

I tried this on report activate event

DoCmd.PrintOut Copies:=CopiesPrint

It prints 10 copies of id 1 jim and stops. How do i print 10 copies of id 1 JIm and proceed to next?

thanks
 
Print reports from a form

Slightly unsure of what you mean.
Is it:
The program should 10 copies of a report based on the record of ID 1
then
print 2 copies of a (the same) report based on record of iD 23
then
print 3 copies of a (the same) report based on record of iD 56


If so and the table is called PrintTable (with just 3 records)

Then something like this will do it

Code:
        Me.UpdatingRecords.Visible = True ' have a caption on the form to show what is happening
        Me.Repaint
        StrSql = "Select ID, Name, Copies from TblPrintTable;" 'the report will already have the data
        Set Rst2 = New ADODB.Recordset
        Rst2.Open StrSql, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
            If Rst2.BOF And Rst2.EOF Then
                Me.UpdatingRecords.Caption = "No Records"
                Me.Repaint
                Set Rst2 = Nothing
                Exit Sub
            Else
                Rst2.MoveFirst
                Intcounter = 0
                Do While Not Rst2.EOF
                    Intcounter = Intcounter + 1
                    'Create the Where string
                    StrID= Rst2.Fields("ID")
                    intCopies = int(Rst2.Fields("Copies"))
                    'if you need a different report for each ID then you can add
                    stReportName = "Rep" & CStr(Intype)
                    st2DocNameSave = "Rep" & StrID ' if saving
                    stWhere = "ID = " & StrID
                    DoCmd.OpenReport stReportName , acViewPreview, , stWhere, acHidden
                    Dim blRet As Boolean
                    ' Call a print function or just loop here
                    PrintLoop = 0
                    Do While PrintLoop < intCopies
                        'not sure the code here as the version I use creates a PDF saves it, emails it where appropraite and prints it if appropriate
                        
                    Loop
                    totalcopies = totalcopies + intcopies ' to give total printed
                    DoCmd.Close acReport, stReportName , acSaveNo
                    
                    ' Update this each time a record completes
                    Me.UpdatingRecords.Caption = "Completed Record - " & Intcounter
                    Me.Repaint
                    Rst2.MoveNext
                Loop
                Set Rst2 = Nothing
            End If
        'The creation is completed
        Me.UpdatingRecords.Caption = Intcounter & " records have been printed with " & totalcopies &" printed.
        Me.Repaint
 
still need help

Thanks Brian1960 for the help. That is actually what i need, but i am still having difficulty getting this going.

Basically, I am trying to print survey (as a report) for each course. Course numbers are unique and course enrollment will let me know how may surveys i have to print for that particular class.

I have attached the sample db (access 2000) with sample report. I created a command on the form to print all surveys and add as well as modified as need to get it going. But it for some reason it is in loop and continue to print first record.


Warning ! command is in loop.
Please help
 

Attachments

  • 1.zip
    1.zip
    15.9 KB · Views: 136
Last edited:

Users who are viewing this thread

Back
Top Bottom