The Form_Timer() calls the module.
Strange...... I would have used the form open event, not the timer event.
Functions return a value, even if you do not use the returned value.
So two options...
Option 1:
Code:
Function DaylightSwitch()
'set a default return value
DaylightSwitch = #12:00:01 AM#
If Forms!frmSchools!State = "QLD" Then
Forms!frmSchools!TxtTime = DateAdd("h", 1, Time())
ElseIf Forms!frmSchools!State = "SA" Then
Forms!frmSchools!TxtTime = DateAdd("n", -30, Time())
ElseIf Forms!frmSchools!State = "WA" Then
Forms!frmSchools!TxtTime = DateAdd("h", 4, Time())
ElseIf Forms!frmSchools!State = "NT" Then
Forms!frmSchools!TxtTime = DateAdd("h", 3, Time())
Else ' do not use the colon (:) in a multi-line IF() function.
Forms!frmSchools!TxtTime = Time()
End If
End Function
Option 2:
Since you are not using the function to return a value, change the timer event code to call a sub...
Code:
Private Sub Form_Timer()
Call DaylightSwitch
End Sub
Code:
Sub DaylightSwitch()
If Forms!frmSchools!State = "QLD" Then
Forms!frmSchools!TxtTime = DateAdd("h", 1, Time())
ElseIf Forms!frmSchools!State = "SA" Then
Forms!frmSchools!TxtTime = DateAdd("n", -30, Time())
ElseIf Forms!frmSchools!State = "WA" Then
Forms!frmSchools!TxtTime = DateAdd("h", 4, Time())
ElseIf Forms!frmSchools!State = "NT" Then
Forms!frmSchools!TxtTime = DateAdd("h", 3, Time())
Else ' do not use the colon (:) in a multi-line IF() function.
Forms!frmSchools!TxtTime = Time()
End If
End Sub