Results 1 to 3 of 3
  1. #1
    Lockrin is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2009
    Posts
    52

    Looping code for printing reports

    Hello All. I have 3 reports that I print on a regular basis. I want to set these to Loop as many times as a table with a "QTY" field says they need to for that shipment. I have a report that is run from a query that filters for the shipment and has the "Job Number" and "QTY" fields. The code I have prints all 3 reports with one button but I need to look at the report to tell it how many of each to print along with entering the "Job Number" every time. The code I use now is as follows:

    Private Sub Command447_Click()

    On Error GoTo Err_Ctl5_Click

    Dim stDocName As String

    stDocName = "Record of Accomplishment"
    DoCmd.OpenReport stDocName, acNormal
    stDocName = "Dimesional Inspection Form"
    DoCmd.OpenReport stDocName, acNormal
    stDocName = "Assembly Drawing"
    DoCmd.OpenReport stDocName, acNormal

    Exit_Ctl5_Click:
    Exit Sub

    Err_Ctl5_Click:
    MsgBox Err.Description


    Resume Exit_Ctl5_Click

    End Sub

  2. #2
    llkhoutx is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Jan 2010
    Location
    Houston, Texas USA
    Posts
    373
    Print the reports in PrintPreview mode, the use Ctl+P and you'll be able to specify the number of copies.

  3. #3
    Lockrin is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2009
    Posts
    52
    That's not really what I want to do. I have 3 separate reports that are printed and all 3 are based on a text box on my switchboard. In order to get the reports printed I need I print a 4th report (which shows how many of each "Job Number" I need). This way works, I just want to simplify the process.

    I came up with this code last night, but it only works with the first record. (I plan on changing the MsgBox to the code needed to print those reports once I get it to go through all the records.)

    Private Sub Print_Click()
    Do While Nz(Me.txtCount.Value) < Ship_Qty
    MsgBox "This is where we'll add the code to print the reports"
    Me.txtCount.Value = Nz(Me.txtCount.Value) + 1
    Loop

    End Sub

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Printing reports and cycling through records
    By dabman in forum Programming
    Replies: 4
    Last Post: 12-15-2009, 11:45 PM
  2. Access 2003 code vs Access 2007 Code
    By ralphjramirez in forum Access
    Replies: 5
    Last Post: 11-23-2009, 12:33 PM
  3. Looping syntax
    By fadiaccess in forum Access
    Replies: 1
    Last Post: 10-23-2009, 02:57 AM
  4. How to automate printing and saving reports
    By lilynet in forum Programming
    Replies: 0
    Last Post: 02-10-2009, 01:33 PM
  5. Printing Reports....
    By Danny Christie in forum Reports
    Replies: 1
    Last Post: 12-06-2006, 05:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums