Link to home
Start Free TrialLog in
Avatar of Svgmassive
Svgmassive

asked on

64 bit vba timer module

I am looking for a working 64  bit vba timer for ms access
thanks
ASKER CERTIFIED SOLUTION
Avatar of crystal (strive4peace) - Microsoft MVP, Access
crystal (strive4peace) - Microsoft MVP, Access

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Svgmassive.

You can use the Timer event of any form. This works regardless of the Access version.

You must specufy the time in miliseconds, and the form fires the event.

A small sample is this one:

'In a form called FormTimer
Private Sub Form_Timer()
    
    ' Your code goes here
    '
    '
    '
    
    'Fired
    MsgBox "Timer fired."
    
    Me.TimerInterval = 0
    
    DoCmd.Close acForm, Me.Name, acSaveNo
End Sub


'In a Standard module

Sub TimerTest()

    Dim mSeconds As Long
    
    mSeconds = 30000 'Assign a 30 seconds pause
    
    DoCmd.OpenForm "TimerForm", acNormal
    
    Forms!TimerForm.Visible = False
    
    'To start the timer
    Forms!TimerForm.TimerInterval = mSeconds
    
End Sub

Open in new window


This code is simple and works.

If you need to pause the code execution more time than a few seconds or minutes, you can also use a Do - Loop.

A sample could be:

Dim TimeStart As Date
    Dim TimeLap As Integer
    Dim TInter As String
    
    'Previous code

    'Pause code
    
    
    TimeStart = Now()
        
    TInter = "s" ' for seconds
    'TInter = "n" ' for minutes
    'TInter = "h" ' for hours
    'TInter = "d" ' for days
    
    Do
        DoEvents
        
    Loop Until DateDiff(TInter, Now, TimeStart) >= TimeLap

    'Code follows here

Open in new window


I hope this be helpful.

Best regards.

Antonio. (Barcelona, Spain)