Just really curious. Like I know there is no Sleep/Wait/Pause functions in VBA. But is it possible to maybe try a DoEvents with While loop to delay a button from being enabled?
Because say I had the following code which has a button disabled from another event. Say that once I click on New Record, the button enables:
But what if I wanted the button to be enabled on new record only after a certain amount of time. For example 5 seconds? Essentially delaying the Me.cmdButton.Enabled = False code.
I mean I know I can create a Sleep module and then say Sleep 5000 before the code.
But this would simply freeze the form for 5 seconds right? DoEvents would be the more logical way of doing it?
Just a thought crossing my mind for the sake of learning more about VBA. Thanks.
Because say I had the following code which has a button disabled from another event. Say that once I click on New Record, the button enables:
Code:
Private Sub cmdNewRecord_Click
DoCmd.GoToRecord , , acNewRec
If Me.NewRecord Then
Me.cmdbutton.Enabled = True
End If
End Sub
But what if I wanted the button to be enabled on new record only after a certain amount of time. For example 5 seconds? Essentially delaying the Me.cmdButton.Enabled = False code.
I mean I know I can create a Sleep module and then say Sleep 5000 before the code.
Code:
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Code:
Sleep 5000
Me.cmdButton.Enabled = False
But this would simply freeze the form for 5 seconds right? DoEvents would be the more logical way of doing it?
Just a thought crossing my mind for the sake of learning more about VBA. Thanks.