DoEvents !!!!!!!! Duh !
Ya know, sometimes things just don't click ? I missed a major turn on this one. I don't have a clue how "DoEvents" is used, even tho I have read till I am blue in the face ! It just does not turn the little light on for me. Duh !
I understand it turns loose, so I can click on the form and I am using a timer around it.
I am running a loop 24/7 and need to be able to stop it if we are not using the program. I start it with a form check box and when I try to use same box or another box to stop it... it hollers about my macro or function being updated or trying to save...
I just don't understand what goes along with the "DoEvents" line. What other lines are associated with the "DoEvents"? Can anyone explain the "DoEvents" differently that all the help comments? Guess I need it in dummy words, even tho I do have a fairly good understanding of vb an access.
I call the loop from the check box, which calls a macro to call a function that runs the loop. Sheesh, I am getting so goofy on this that I am not making much sense ! LOL
-----------------------------------------------------------
Private Sub AutoON_Click()
Dim PauseTime, Start, Finish, TotalTime
Dim aon As Integer
aon = Forms!AutoA!AutoON
Do While aon = -1
PauseTime = 5
Start = Timer
aon = Forms!AutoA!AutoON
Do While Timer < Start + PauseTime
DoEvents
Loop
Finish = Timer
TotalTime = Finish - Start
aon = Forms!AutoA!AutoON
Forms!AutoA!AutoON.SetFocus
Loop
End Sub
-----------------------------------------------
This runs fine, until I hit the button again. Then I get the following message.
"The macro or function set to the BeforeUpdate or ValidateRule property for this field is preventing MicroSoft from saving the data in the field."
Ya know, sometimes things just don't click ? I missed a major turn on this one. I don't have a clue how "DoEvents" is used, even tho I have read till I am blue in the face ! It just does not turn the little light on for me. Duh !
I understand it turns loose, so I can click on the form and I am using a timer around it.
I am running a loop 24/7 and need to be able to stop it if we are not using the program. I start it with a form check box and when I try to use same box or another box to stop it... it hollers about my macro or function being updated or trying to save...
I just don't understand what goes along with the "DoEvents" line. What other lines are associated with the "DoEvents"? Can anyone explain the "DoEvents" differently that all the help comments? Guess I need it in dummy words, even tho I do have a fairly good understanding of vb an access.
I call the loop from the check box, which calls a macro to call a function that runs the loop. Sheesh, I am getting so goofy on this that I am not making much sense ! LOL
-----------------------------------------------------------
Private Sub AutoON_Click()
Dim PauseTime, Start, Finish, TotalTime
Dim aon As Integer
aon = Forms!AutoA!AutoON
Do While aon = -1
PauseTime = 5
Start = Timer
aon = Forms!AutoA!AutoON
Do While Timer < Start + PauseTime
DoEvents
Loop
Finish = Timer
TotalTime = Finish - Start
aon = Forms!AutoA!AutoON
Forms!AutoA!AutoON.SetFocus
Loop
End Sub
-----------------------------------------------
This runs fine, until I hit the button again. Then I get the following message.
"The macro or function set to the BeforeUpdate or ValidateRule property for this field is preventing MicroSoft from saving the data in the field."
Last edited: