I am using the following code so that a combo box automatically shows the current shift when a form is loaded:
Dim T As Date, T1 As Date, T2 As Date, T3 As Date
T = TimeValue(Now())
T1 = #6:30:00 AM#
T2 = #2:30:00 PM#
T3 = #10:30:00 PM#
If T < T1 Or T >= T3 Then
Me.Shift = "3rd"
ElseIf T < T2 Then
Me.Shift = "1st"
Me.Shift = "2nd"
Most of the time it has worked flawlessly, but in the 7 days that this database has been up and running, there has been three times, including this morning, that a runtime error is generated that says "You cant assign a value to this object". This morning, When I opened the debugger after recieving the runtime error, the line of code that was highlighted was: Me.Shift = "1st".
The last time this happened was last Wed - exact same scenario, and the same line of code was highlighted.
Any ideas what is going on, why it is only happening sporadically, and how I can prevent it from happening at all?