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

Enable/disable or start/stop timer on form ? 1

Status
Not open for further replies.

vamoose

Programmer
Oct 16, 2005
320
MX
I have 4 Access 2000 forms named frm1,frm2,frm3 and frm4. Each one has a 10 second timer on it which when executed calls the next form to display. I would like to open all the forms hidden on startup and enable the timer and set visibility to true on frm1, then disable the timer and set visibility to false on frm1. Is this timer enable/disable function possible ?

Thank you for the help.
 
What do you mean by disable? I don't think there is a way that you can have access just ignore the event but you could use Global Variables to just not do anything in the events. For example create the below global vairables in a module

Public blnFrm1 as boolean
Publicl blnFrm2 as boolean
...
...

Then in the frm1 Timer event use an if statement to test if the value is true or false

if blnFrm1=true then
run the code
end if
 
You can change the Timer Interval property at runtime. Setting it to zero will prevent the code from running.

Ed Metcalfe.

Please do not feed the trolls.....
 
try

me.timer = 0

The trouble with doing this, once the timer is 'disabled' the form won't be given the focus again and you won't be able to reactivate the visibility and reset the timer value again.

I suggest you create another form which remains invisible and use a time value on this form to call a procedure which make each form visible in turn. Which is what I think you are trying to do.

Try something like this on the control form...

in the on load event
public counter as integer
counter = 1

in the timer event
change the visible property of the 'frm & counter' form
increase the counter
if the counter > 4 then counter = 1


Ian Mayor (UK)
Program Error
Always make your words sweet and nice. Because you never know when you may have to eat them.
 
Well you Question is a little bit vague if I've understood you correctly you are trying to open one form, start a timer that goes to 10 sec or 10sec to 0. I've worked alot with timers and countdowns and it would help if you were a little more specific on what you are attempting to do.
 
What I am trying to do is this: I would like to open all 4 forms, each with their own 10 second timer, and disable their timers. What is happening now is that when I open all 4 forms, hidden, their timers are still active and executing while hidden. I am trying to smooth out the transitions between forms by making only one form visible at a time and activating it's timer. Then this active forms timer times out, set this form visibility to hidden, disable it's timer and set the second form to visible and activate it's timer and so on. The transition between forms now is not as smooth and clean as I would like it to be.

Thank you
 
Hmm, Well it might help if I knew why they were hidden to begin with, but try something like this.

Private Sub formname_Load()

Me.Form.Visible = False

End Sub

Private Sub formname_Timer()

Dim cntdwn As Date
Dim cntdur As Date
Dim iCount As Integer

If Me.Form.Visible = False Then
Me.Form.TimerInterval = 0
Else
Me.Form.TimerInterval = 1000
End If

cntdur = "00:00:10"
iCount = cntdur - 00:00:01

End Sub

This is just quick off the top of my head, if I had more time to play arround with it I'm sure I could come up with something. The key is to set the TimerInterval to 0 if the form is invisible. If the Form is Visible then your TimerInterval should be 1000 (or everysecond). Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top