Thrys5
Thrys5

Reputation: 71

How to get vba code to run every 3 seconds? (Access)

I'm trying to write an update script to update missing values.

    Function InsertAny()
    MsgBox ("Hello")

    callAgain
End Function

Function callAgain()
    Dim alertTime As String
    alertTime = Now + TimeValue("00:00:03")
    Forms("HiddenForm1").OnTime alertTime, "InsertAny"
    'Forms("HiddenForm1").TimerInterval = 3

End Function

However I keep getting :

Run-time error '2465': Application-defined or object-defined error.

Upvotes: 0

Views: 1754

Answers (1)

Sergey S.
Sergey S.

Reputation: 6336

In this case error 2465 appears because you used Form instead of Application. Form expects property: OnTimer, not OnTime.

Edit

As I understand, you need to call InsertAny every 3 seconds. In this case just place

Call InsertAny()

in OnTimer event of HiddenForm1 form and start timer by code

Forms("HiddenForm1").TimerInterval = 3

Upvotes: 1

Related Questions