I have the following script in public module. I'm using the system time to enter the shift name (1st, 2nd, or 3rd) into a text box control (ShiftTXT). When I move to new record the ShiftTXT control is either empty or contains the #Name? error.
If the control is empty, then when I enter something in another control, the #Name? error populates the control. What am I doing wrong? I have another module that evaluates toggle buttons and other control settings and works without a problem.
Code:
Option Compare Database
Option Explicit
Public Sub Shift()
If Time$() < "07" Then
Screen.ActiveForm.ShiftTXT = "3rd Shift"
ElseIf Time$() > "15" Then
Screen.ActiveForm.ShiftTXT = "2nd Shift"
Else: Screen.ActiveForm.ShiftTXT = "1st Shift"
End If
End Sub
I'm using =Shift() in the default value property option for the ShiftTXT control. Do I have my module script set up incorrectly or is it an issue with my form property? I've used both the SUB and FUNCTION options with the same results-. Screen below to show the error.