Share via

Print Reports with a pause

Anonymous
2010-10-11T12:24:52+00:00

I have some code that i use to print a report and after the report it goes out to print a tif image with a 3rd part exe.  The tif image is being printed across the internet so it could take a few seconds or 2 or 3 minutes...depending on the size of the image.  The report has multiple records and it prints 1 record then the tif image(s) then loops back and goes to record 2 and the tif images that goes with it.  How do i get it to pause and wait till it is finished printing that tif image before it goes and prints the next record of the ms report?

My code:

Private Sub Print_Click()

Dim rst As Recordset

Dim db As Database

Dim temp As String

Dim svrname As String

Set db = CurrentDb

Set rst = db.OpenRecordset("imagepaths", dbOpenDynaset)

svrname = fOSMachineName

If rst.EOF = True And rst.BOF = True Then

    Exit Sub

Else

rst.MoveLast

rst.MoveFirst

temp = "0"

Do Until rst.EOF = True

If temp <> rst![CLAIMNO] Then

    DoCmd.OpenReport "Claim_Assembler1", acViewNormal, , "[CLAIMNO2]=" & rst![CLAIMNO2]

    Delay 5

End If

If Right(LTrim(RTrim(rst![IMAGEPATH])), 3) = "TIF" Or Right(LTrim(RTrim(rst![IMAGEPATH])), 3) = "JPG" Then

'usbPrintFile rst![ImagePath]

ShellandWait ("\" & svrname & "\Imdex\ImdexPrintFitPageLandscape.exe " & rst![IMAGEPATH])

'Delay 3

End If

temp = rst![CLAIMNO]

rst.MoveNext

Loop

End If

End Sub

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

12 answers

Sort by: Most helpful
  1. Anonymous
    2010-10-11T16:07:00+00:00

    Where you have Loop...  put it after that...

    Your code

    Loop

    DoEvents

    Are the two If statements your attempt at pausing the code?


    --

    Gina Whipp

    2010 Microsoft MVP (Access)

    Please post all replies to the forum where everyone can benefit.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2010-10-11T15:07:46+00:00

    I've never used doevents...how do i incorporate that into my code?

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2010-10-11T14:18:04+00:00

    Hmmm, then a simple DoEvents might work for you as it will yield to the other processes before proceeding.


    --

    Gina Whipp

    2010 Microsoft MVP (Access)

    Please post all replies to the forum where everyone can benefit.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2010-10-11T14:09:29+00:00

    This does not ensure that my print job will be finished before it starts again.  1 print job can go for 5 seconds and then next for 5 mins. depending on the size of the tif image.

    Was this answer helpful?

    0 comments No comments
  5. Anonymous
    2010-10-11T14:06:44+00:00

    Here are two methods you can use to pause your loop...

    Dim WAIT As Double

    WAIT = Timer

    While Timer < WAIT + 2

       DoEvents  'do nothing

    Wend

    ...and then adding WAIT + *the number of seconds you want to pause the code*.  I would also put it outside the loop because you are looping one record at a time.

    OR

    Private Sub (KillSomeTime)

    'Posted by Austin Myers 8.15.2007

    Dim PauseTime, Start

    PauseTime = 10 ' Set duration in seconds

    Start = Timer ' Set start time.

    Do While Timer < Start + PauseTime

    DoEvents ' Yield to other processes.

    Loop

    End Sub


    --

    Gina Whipp

    2010 Microsoft MVP (Access)

    Please post all replies to the forum where everyone can benefit.

    Was this answer helpful?

    0 comments No comments