Results 1 to 6 of 6
  1. #1
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Location
    Frederick, Maryland, USA
    Posts
    1,788
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Form On Time Event acting strange (A2K SR1)

    I am using a Forms onTimer event to launch some actions. The Timer Interval is set to 1000. The On timer event increments a counter that starts from zero and increases by 1 each time the timer fires. The timer is re-set to zero by a MouseMove or KeyDown event. Here are the problems I have encountered. The timer is set as a public variable.

    1. Upon monitoring the counter, the counter increments by 1, 2, or sometime 3 each time it fires.
    2. The MouseMove event only resets the timer to zero on the first movement and then does not do it again.
    3. The KeyDown event never resets the time.

    Any insights as to why this is happening?? <img src=/S/dizzy.gif border=0 alt=dizzy width=15 height=15>
    Regards,

    Gary
    (It's been a while!)

  2. #2
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form On Time Event acting strange (A2K SR1)

    Gary,

    I had this great reply already for you, then I went back to reverify my tests and I duplicated exactly what you said.

    That being said, here is what I can figure

    1) The way i was monitoring the counter was to change the caption of the form and occasionally it would jump 2 or 3. For me, I think it is because of the screen refreshing too slowly, so it would only refresh every other time the counter changed. So I suspect you are running into a similar challenge.

    2) Is your MouseMove Event the form's mousemove event? You may need to add your code to all the controls on the form, including the details section. Once I added the Details MouseMove event to reset the counter, as long as the mouse pointer was over the form, even not moving, the event would fire. To get around this, I would suggest static variables in the Detail MouseMove event to track the last position of the mouse pointer and only if they are different reset the counter.

    3) Does the Form KeyDown event even fire? If not, I would suspect that you don't have the Form's Key Preview property set to yes.

    All this make sense?
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  3. #3
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Location
    Frederick, Maryland, USA
    Posts
    1,788
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Form On Time Event acting strange (A2K SR1)

    Bryan,

    Thanks for the reply.

    Items 1 and 3 make sense.

    Item 2 sounds like too much work except for perhaps the detail section, which I will have to try. I used a text box to display the current counter on the form while it was active. I have used this method for reviewing loops before and have never had a problem. Perhaps the refresh is causing a problem, I just don't know.

    Thanks for the suggestions.
    Regards,

    Gary
    (It's been a while!)

  4. #4
    4 Star Lounger
    Join Date
    Aug 2002
    Location
    Dallas, Texas, USA
    Posts
    594
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form On Time Event acting strange (A2K SR1)

    How are you determining that it is incrementing it wrong? Are you stepping through the code, or simply watching a counter? Timer events WILL back up. Which means that if a piece of code takes 3 or 4 cycles of a timer to complete, the timer event will fire 3 or 4 times right in a row. A good example of this is setting the timer interval to 1000, and just having it set a label's caption to Now(). That makes a simple clock. However, if you watch that clock as you use other objects in your database, you'll notice that it is going to skip a bit here and there. Setting the timer event to 100 fixes most situations except for long code runs.... (You need a doevents for that, but you must be careful that other events don't fire that will 'hurt' the function with DoEvents in it.)

    Drew

  5. #5
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Location
    Frederick, Maryland, USA
    Posts
    1,788
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Form On Time Event acting strange (A2K SR1)

    Drew,

    I took the lazy way out and did not step through the code. Setting the timer to 100 seems to have fixed the issue at hand.

    Thanks
    Regards,

    Gary
    (It's been a while!)

  6. #6
    4 Star Lounger
    Join Date
    Aug 2002
    Location
    Dallas, Texas, USA
    Posts
    594
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form On Time Event acting strange (A2K SR1)

    Hey, if it works, it works! <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •