Timer event problem

Hassan

Registered User.
Local time
Today, 11:47
Joined
Feb 24, 2000
Messages
15
Hi!
I have problem with my timer event.
When I click mouse button ok some key on
keyboard my event stops, wen I release button
or key it continues to run.
Why it is so? What I have to change there?

Here is my code:

Option Compare Database
Option Explicit
Dim kaza, aaa As Long
Dim sony As String
Private Sub Form_Timer() 'MsgBox when time is out
Dim Msg As String
Dim title As String
Dim style As Integer
Dim stDocName, stLinkCriteria As String

sony = sony & "*"
kaza = kaza + 1
Text68.ForeColor = rgb(0, 0, 255) 'Time line with * symbols
Text69.ForeColor = rgb(0, 0, 255)
Text68 = sony
Text69 = sony
Text42 = kaza
If kaza = 60 Then
Msg = "Your time is over"
style = vbOKOnly + vbInformation
title = "Information"
MsgBox Msg, style, title
DoCmd.Close
stDocName = "My_form"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
End Sub
 
It may be because your timer is still running. Here is the section of your code where you need to set the timer to 0:

If kaza = 60 Then
Me.TimerInterval = 0
Msg = "Your time is over"
style = vbOKOnly + vbInformation
title = "Information"
MsgBox Msg, style, title
DoCmd.Close
stDocName = "My_form"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If

Also another point to be made:
In your Declaration lines you have one line that says:

Dim kaza, aaa As Long

I think you are trying to declare both "kaza" and "aaa" as long integers. If you don't put the "As Long" on it, even if they are on the same line, Access will automatically declare it as a Variable. It needs to be:

Dim kaza As Long, aaa As Long

The way you have it Declares "kaza" as a variable. It will work but it's not what you are attempting to do. Also "kaza" should only be an Integer, so to be correct the line should be:

Dim kaza As Integer, aaa As Long

I'm not trying to be critical, only trying to be helpful and give you some insight.

Good luck with your project,
RDH


[This message has been edited by R. Hicks (edited 02-27-2000).]
 
Thank your for your help, I made these changes you gave me, but it still doesn't
work. On pressed or clicked button my timer stops.
 
Try moving the two declarations before the sub, into the sub. It should look like this:

Option Compare Database
Option Explicit

Private Sub Form_Timer() 'MsgBox when time is out
Dim kaza, aaa As Long
Dim sony As String
Dim Msg As String
Dim title As String
Dim style As Integer
Dim stDocName, stLinkCriteria As String

sony = sony & "*"
kaza = kaza + 1
Text68.ForeColor = rgb(0, 0, 255) 'Time line with * symbols
Text69.ForeColor = rgb(0, 0, 255)
Text68 = sony
Text69 = sony
Text42 = kaza
If kaza = 60 Then
Me.TimerInterval = 0
Msg = "Your time is over"
style = vbOKOnly + vbInformation
title = "Information"
MsgBox Msg, style, title
DoCmd.Close
stDocName = "My_form"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
End Sub

Maybe this will help
RDH
 

Users who are viewing this thread

Back
Top Bottom