Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing/collating 2 reports

Status
Not open for further replies.

itsuit

IS-IT--Management
Apr 23, 2002
53
US
This was originally posted in Access Modules, but I thought it might be more appropriately posted here:

I work for an insurance company, and the person in the job before me set up an Access form to print 2 reports at the same time (checks and Explanation of Benefit - EOB - forms). If a check is linked to an EOB, Access should first print the check, then the EOB immediately behind it. If the check is not linked, it prints the check and moves to the next one. He wrote some code to print EOB's with their corresponding checks (linked by the field "check_key") as follows:


Code:
Private Sub Command1_Click()
On Error GoTo Err_Command1_Click

    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim rsEOB As DAO.Recordset
    Dim PauseTime, Start
    Set db = CurrentDb
    Set rs = db.OpenRecordset("select DISTINCT CHECK_KEY, CHECK_NUMBER from ALYCE_REPORTS_CHECK_PRINTING_QUERY ORDER BY CHECK_NUMBER")
    rs.MoveFirst
    
    Do Until rs.EOF
        
        DoCmd.OpenReport "Checks", acViewNormal, , "CHECK_KEY = " & Chr(34) & rs!CHECK_KEY & Chr(34)
    Set rsEOB = db.OpenRecordset("select * from ALYCE_REPORTS_EOB_PRINTING_QUERY where CHECK_KEY = " & Chr(34) & rs!CHECK_KEY & Chr(34))
    If Not rsEOB.EOF Then
    rsEOB.MoveFirst
    PauseTime = 5                            ' Set duration.
    Start = Timer                            ' Set start time.
    Do While Timer < Start + PauseTime
        DoEvents                                ' Yield to other processes.
    Loop
    
        DoCmd.OpenReport "EOB", acViewNormal, , "CHECK_KEY = " & Chr(34) & rs!CHECK_KEY & Chr(34)
    
    End If
    
    If Not rs.EOF Then rs.MoveNext
    
    Loop
    
    
    rsEOB.Close
    Set rsEOB = Nothing
    rs.Close
    Set rs = Nothing
    Set db = Nothing
    
    DoCmd.Close
    
Exit_Command1_Click:
    Exit Sub

Err_Command1_Click:
    MsgBox Err.Description
    Resume Exit_Command1_Click
    
       
End Sub

The problem is that when the first check *not* linked to an EOB prints, it throws off the rest of the batch, and the checks and EOBs print out of order. Can anyone look this over and let me know if they see the problem that's causing this?

Any help is appreciated.

-------
Kyle
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top