Share via

Pause Code for a few seconds

Anonymous
2013-06-19T04:40:24+00:00

My reoprt is based upon a query that can not get its data untill the insert statement has written its data to the table. Is there any way to insert about a 5 second delay between the insert statement and the openreort command?

    strSQL = "INSERT INTO tbl_Bank(ChangeDate, PlayedAmount, PlayerID) SELECT " & Format(Me.txt_ChangeDate, "#yyyy/mm/dd#") & ",  " & Me.txt_Wager & ",PlayerID FROM qry_Bank"

        DoCmd.RunSQL strSQL

DoCmd.OpenReport "rpt_GamePlayed", acViewNormal

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

4 answers

Sort by: Most helpful
  1. Anonymous
    2013-06-26T18:58:10+00:00

    I agree CurrentDb.Execute is the way to do it !!

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2013-06-19T22:29:25+00:00

    There is no need to wait.  Instead of using the asynchronous RunSQL method, use the Execute method that doesn't return until the query has completed:

       CurrentDb.Execute strSQL, dbFailOnError

    Was this answer helpful?

    0 comments No comments
  3. ScottGem 68,830 Reputation points Volunteer Moderator
    2013-06-19T14:05:30+00:00

    You can also use the Sleep() function

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2013-06-19T04:58:32+00:00

    Checkout the Timer Function --

    This example uses the Timer function to pause the application. The example also uses DoEvents to yield to other processes during the pause.

    Dim PauseTime, Start, Finish, TotalTime
    If (MsgBox("Press Yes to pause for 5 seconds", _
            4)) = vbYes Then
        PauseTime = 5    ' Set duration.
        Start = Timer    ' Set start time.
        Do While Timer < Start + PauseTime
            DoEvents    ' Yield to other processes.
        Loop
        Finish = Timer    ' Set end time.
        TotalTime = Finish - Start  ' Calculate total time.
        MsgBox "Paused for " & TotalTime & " seconds"
    Else
        End
    End If
    

    Was this answer helpful?

    0 comments No comments