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

TimerInterval Problems

Status
Not open for further replies.

trudye10

Programmer
Sep 8, 2006
67
Hi Guys, I am trying to execute a function every minute. It works the first time, the intervalTimer waits a minute before it exec the code the first time, after that it exec it every second. How can I get it exec every 60 seconds?

Code:
Private Sub Form_Timer()

Me![lblclockview].Caption = Time

Do While cnt < 6
    If Me.TimerInterval = 60000 Then
        Time_To_Compress
        cnt = cnt + 1
        Me![lblCountWarnings].Caption = cnt
    End If
Loop
End Sub

Thanx,
Trudye
 
How about:

Code:
Private Sub Form_Timer()

Me![lblclockview].Caption = Time

cnt = Val(Me![lblCountWarnings].Caption)
    If cnt < 6 Then
        Time_To_Compress
        cnt = cnt + 1
        Me![lblCountWarnings].Caption = cnt
    End If

End Sub

Make sure that you have set the TimerInterval to 1000 (1 minute).
 
Remou, thank you so much for responding so quickly. I have question, why does cnt jump from 0 to 3 on the very first pass thru the code?

After this code is exec cnt is eq to 3(cnt = Val(Me![lblCountWarnings].Caption). I know I'm missing something just not sure what.

Thanx,
Trudye


 
Basically sends msgs to users. Here is the code:

Code:
Function Time_To_Compress()
Dim db1 As Database
Dim rs1 As Recordset

Set db1 = DBEngine(0)(0)
Set rs1 = db1.OpenRecordset("Log_Em_Off", dbOpenDynaset)

rs1.Edit
    rs1!Msg_Count = rs1!Msg_Count + 1
rs1.Update


If rs1!Msg_Count = 2 Then
    MsgBox "The system will be logging off in 6 minutes for maintenance. Please close the database. Thanx"
End If

If rs1!Msg_Count = 3 Then
    MsgBox "The system will be logging off in 3 minutes for maintenance. Please close the database. Thanx"
End If

If rs1!Msg_Count = 4 Then
    MsgBox "The system will be logging off in 1 minutes for maintenance. Please close the database. Thanx"
End If

If rs1!Msg_Count = 5 Then
    MsgBox "Good Bye"
    rs1.Edit
        rs1!Msg_Count = 0
    rs1.Update
    DoCmd.Close acForm, "frmCompress"
    Application.Quit
End If


End Function

Thanx,
Trudye
 
Is it possible that
rs1!Msg_Count + 1

Is written to Me![lblCountWarnings].Caption ?

I do not think you need a counter in two places.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top