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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with TIMER and EVENTS

Status
Not open for further replies.

TheWizard78

Programmer
Jun 28, 2004
18
CA
Hi group,

I have a little problem. I have a form with 10 buttons + a timer on it. When I try to click on a button during the execution of the timer, I have so many weird things that appens to me. In the button1.click coding, I select table1 to do something. In the timer1.timer coding, I select table2 to do other things + some refresh. These 2 tables does not have the same column name. So I receive many errors messages, because during the time I select a table and then try to use it to replace or everything else, the timer change my default selected table.

I would like to be able to wait until the end of the timer event before running my code in the button1.click.

If there's a way to do it, please tell me how, you will save me a lot of works and search.

p.s. the form with 10 buttons + 1 timer is just an example, the real one is very more complexe than that.

Thanks

The Wizard
 
Hi Wizard

Can you think of Timer event calling another form which can run the required activity behind your current form. That way, you can have differnt private data environments. Those tables can be read by your current form as and when required .. may by by requerry().

:)

____________________________________________
ramani - (Subramanian.G) :)
 
Thank you Ramani for your quick response.

No I can't do that in another form, because I need to refresh some object on my main form. And some time, user need to swip some barcode card. That's why i'm trying to complete the execution of the timer before being able to do whatever else.

There's a lot of interaction on that form, (Keyboard, mouse, barcode reader, timer event, ...)

Do you think that DOEVENTS could be good for me?

The Wizard
 
It sounds as though the timer is changing something global so that the button event fails. You say that the timer and button events work with different tables. I suspect that the timer is flipping something like SET EXACT or SET DELETED or is switching you to a different work area.

If you want to prevent the user clicking a button whilst the timer's running you could disable the buttons at the start of the timer code and enable them when it finishes. Similarly you could disable the timer whilst the button events are running.

That would make the captions on the buttons flicker between enabled and disabled. A nicer solution would be to set a form property when the timer event starts and add a loop to each button event so that it didn't start processing data until the timer had finished.

Geoff Franklin
 
Thanks to you alvechurchdata for your response.

I just thought that there was an easyest way to do it, instead of having to disabled the timer on each object event. and disable object during the timer event.

Do you think that I can just use «thisform.enabled=.f.» when my timer is running or I really need to disabled each object. It's just because I have a couple of object depending on client configuration and country, that are already disabled and I cannot use the setall() method to put them enabled=.f. the first time and then enabled=.t. the second time because they need to stay disabled all the time.

If there are no other way to do it, I think I will not have the choice, I will do it like this..

The Wizard
 
The best answer is to find out why the timer is fouling the button events and to fix that problem. If there's no more time to follow that solution then:
Code:
*-- In Timer
ThisForm.TimerRunnning = .T.
*-- The rest
*--    of the timer
*--        event code
ThisForm.TimerRunning = .F.

*-- At the start of each Button click
DO WHILE ThisForm.TimerRunning = .T.
  *-- Do nothing and wait for the timer to finish
ENDDO
*-- The rest of the button code

But this is a kludge and there's still something wrong in your timer code which needs to be fixed.

Geoff Franklin
 
Thanks to you alvechurchdata for your response.

I have tried something similar to your answer and seems to work better now. Now, I will wait and cross my finger.

The Wizard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top