Resume Timer

User avatar
burrina
4StarLounger
Posts: 550
Joined: 30 Jul 2014, 23:58

Resume Timer

Post by burrina »

Need to resume timer when 1 form closes and start timer again on other form
frmregister is the form that is open and when it closes I need frmLogin timer to start again.
The TimeCount should be set to 30 seconds
TimerInterval set to 1000
TimeCount = TimeCount + 1
I think this is correct

User avatar
HansV
Administrator
Posts: 74154
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Resume Timer

Post by HansV »

What is TimeCount?
Regards,
Hans

User avatar
burrina
4StarLounger
Posts: 550
Joined: 30 Jul 2014, 23:58

Re: Resume Timer

Post by burrina »

Dim TimeCount As Long
'Declare a Form Global variable to hold the
'seconds expired since Form was opened.

User avatar
burrina
4StarLounger
Posts: 550
Joined: 30 Jul 2014, 23:58

Re: Resume Timer

Post by burrina »

Code: Select all

Private Sub Form_Timer()
'Increment the TimerCount variable by 1
   TimeCount = TimeCount + 1
   'Display the current seconds remaining in the
   'small Label control located in the upper right
   'corner of the Form.
   Me.Cnter.Caption = 20 - TimeCount
   'If the Seconds Counter (TimerCount) is now equal
   'to 61 seconds then Close the Password Entry Form.
   If TimeCount = 21 Then
   DoCmd.quit
   
 End If


Private Sub Form_Unload(cancel As Integer)
'When the Form closes or is put into Design view
   'then Zero the Form's TimerInteval. If you don't
   'it can cause some strange things to happen.
   Me.TimerInterval = 0
   
End Sub

User avatar
HansV
Administrator
Posts: 74154
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Resume Timer

Post by HansV »

I assume that the code that you posted is in the code module of frmLogin.
If so, the variable TimeCount will not be available in the code module of frmRegister.
To correct this, remove the declaration of TimeCount from frmLogin and place it in a standard module, near the top:

Public TimeCount As Long

If you want to reset the count to restart it, you should use

TimeCount = 0
Regards,
Hans

User avatar
burrina
4StarLounger
Posts: 550
Joined: 30 Jul 2014, 23:58

Re: Resume Timer

Post by burrina »

Did you mean adding all of the code to the module?

User avatar
HansV
Administrator
Posts: 74154
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Resume Timer

Post by HansV »

No, just the declaration of TimeCount

Public TimeCount As Long
Regards,
Hans

User avatar
burrina
4StarLounger
Posts: 550
Joined: 30 Jul 2014, 23:58

Re: Resume Timer

Post by burrina »

Ok, Thanks