Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stop On Current Event

Status
Not open for further replies.
Oct 28, 2003
50
MY
Hi all,
Does anybody knows how to stop On Current Event? I have a loop under On Current event which will keep looping until time >= 9.00 a.m. When current time reach or exceed 9.00 am I want to stop the looping under the Form's On Current event.I've tried to put the coding in the On Timer event but it makes my mdb hang.Can someone help me out with this problem? Thank you
 
cenderawasih

You could use a simple comparison to exit the loop. But you have to be darn careful because you could lock the workstation.

Code:
Dim lngCount as Long

lngCount = 0

Do While Format(Time(Now()), "hh:mm AMPM") < "09:00 AM"
    If lngCount Mod 5000 = 0 Then
        DoEvents
    End If
    lngCount = lngCount + 1
Loop

I use the DoEvents command to allow the system to gain control every time it hits a number divisible by 5000 -- otherwise, your PC would be locked. The program will keep counting until 9:00 AM. But my question is what do you do later? Say after 5:00 PM?

The program will crash if the counter exceeds the maximum of a long interger, 2,147,483,647

Perhaps another approach, would be to use the OnTimer event with TimerInterval.

Richard
 
How are ya cenderawasih . . . . .

Curious . . . . post the code!

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top