2 timer events

jamesd

Board Regular
Joined
Sep 22, 2003
Messages
220
I have a form that requerys every 30 seconds using the forms timer event.
I would also like to have one of the labels flashing.
As both would need the on timer event , can this be done.
Ie
set Me![Text27].Visible = Not (Me![Text27].Visible) to 600 and
set docmd.requery to 30000
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Set the form's timer Interval to 1000 (for 1 second). Then set the code like this:

Rich (BB code):
Private Sub Form_Timer()
' static will keep the value and not reset
' on every event fire
Static lngCount As Long
 
' check to see if we have gotten to 30000 and, 
' if so, do the requery
If lngCount = 30000 Then
   Me.Requery
   ' reset the count to start over 
   lngCount = 0
End If
 
Me.Text27.Visible = Not Me.Text27.Visible
lngCount = lngCount + 1
 
End Sub
 
Upvote 0
Thanks for this but sorry I can not get it to work

When I do as you say and past the code, the text flashes but the form does not requery ?
 
Upvote 0
If lngCount >= 30000 Then 'Whats the odds of it being exactly 30000?
Me.Requery
' reset the count to start over
lngCount = 0
End If
 
Upvote 0
If lngCount >= 30000 Then 'Whats the odds of it being exactly 30000?
100% if 1+1 = 2

Your statement is illogical. Think about it. The Timer event fires and, every time the Timer event fires, it adds one to the lngCount. So at some point it will equal 30,000 because it isn't based on an actual time, but on the number of times the Timer event fires. So your statement is completely incorrect. :stickouttounge:
 
Last edited:
Upvote 0
Thanks for this but sorry I can not get it to work

When I do as you say and past the code, the text flashes but the form does not requery ?

Set a Watch and have it stop when lngCount = 30000. Then F8 through the code to see if it enters the If and does the requery. Also, make sure you aren't really trying to requery a subform on the main form. That would require

Me.SubformControlNameHere.Form.Requery

instead of

Me.Requery

(and where SubformControlNameHere is the name of the subform control which houses the subform on the parent form and not the name of the subform itself unless they are exactly the same. And that .Form. part is put in exactly as shown)
 
Upvote 0
You are correct, with a number of 30,000 I figured that it was milliseconds, sorry. The form will not requery for 8 hours and 20 min+ -, maybe we should change the 30,000 to 30?
 
Upvote 0
You are correct, with a number of 30,000 I figured that it was milliseconds, sorry. The form will not requery for 8 hours and 20 min+ -, maybe we should change the 30,000 to 30?

I did forget to account for the 1000 timer interval. Yes, the count should be changed to 30 and the check changed to 30.
 
Upvote 0

Forum statistics

Threads
1,224,798
Messages
6,181,037
Members
453,013
Latest member
Shubashish_Nandy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top