Prevent OnTimer

S

scadav

I have setup an OnTimer event on one of my forms. One of the first things
it does is check to see if the db is configured to run the "automatic
check". It does this by checking a flag in the database. If it is
configured to run this check, it will run the procedure. If it is not
configured it will exit the procedure.
Given this db is going to be up all day, after the OnTimer Event time
interval is reached, the system is constantly going to be attempting to run
this procedure. Which leads me to my question...is it possible to prevent
the system from even going to the OnTimer Event if a flag in the db is
configured not to run OnTimer Event? I would rather save events from
firing off if they are unnecessary.

Below is the code I am using:



Private Sub Form_Timer()

Dim sWorkOrderStatusWarningTurnOn As String
sWorkOrderStatusWarningTurnOn = DLookup("[ParameterValue]",
"sys_SystemParameters", "[ParameterID] = " & 4)

'Means the user has turned on the functionality
If (sWorkOrderStatusWarningTurnOn = 1) Then
RemindUser
End If

End Sub
 
D

Damian S

Hi scadav,

The way to prevent On Timer events from firing is to set the Timer Interval
to 0, so on the Open Form event you might like to have something like this:

Dim sWorkOrderStatusWarningTurnOn As String

sWorkOrderStatusWarningTurnOn = DLookup("[ParameterValue]",
"sys_SystemParameters", "[ParameterID] = " & 4)

'Means the user has turned on the functionality
If (sWorkOrderStatusWarningTurnOn = 1) Then
me.timerInterval = 1000
else
' No timer events
me.timerinterval = 0
End If

Then, simply have your timer event call RemindUser, as it will only fire if
the flag is set.

Damian.
 
S

scadav

Hi scadav,

The way to prevent On Timer events from firing is to set the Timer Interval
to 0, so on the Open Form event you might like to have something like this:

Dim sWorkOrderStatusWarningTurnOn As String

sWorkOrderStatusWarningTurnOn = DLookup("[ParameterValue]",
"sys_SystemParameters", "[ParameterID] = " & 4)

'Means the user has turned on the functionality
If (sWorkOrderStatusWarningTurnOn = 1) Then
me.timerInterval = 1000
else
' No timer events
me.timerinterval = 0
End If

Then, simply have your timer event call RemindUser, as it will only fire if
the flag is set.

Damian.



scadav said:
I have setup an OnTimer event on one of my forms. One of the first things
it does is check to see if the db is configured to run the "automatic
check". It does this by checking a flag in the database. If it is
configured to run this check, it will run the procedure. If it is not
configured it will exit the procedure.
Given this db is going to be up all day, after the OnTimer Event time
interval is reached, the system is constantly going to be attempting to run
this procedure. Which leads me to my question...is it possible to prevent
the system from even going to the OnTimer Event if a flag in the db is
configured not to run OnTimer Event? I would rather save events from
firing off if they are unnecessary.
Below is the code I am using:
Private Sub Form_Timer()
Dim sWorkOrderStatusWarningTurnOn As String
sWorkOrderStatusWarningTurnOn = DLookup("[ParameterValue]",
"sys_SystemParameters", "[ParameterID] = " & 4)
'Means the user has turned on the functionality
If (sWorkOrderStatusWarningTurnOn = 1) Then
RemindUser
End If
End Sub- Hide quoted text -

- Show quoted text -

Brilliant. Thank you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top