Code works when stepping thru, but doesnt when running

This is an MS Access form and when I step through the code is works fine, but when I run the code it sets the txtErr text box to #name?. I orginally used a select case statement and switched to IFs to see if that helped.

Mnth = Format(Date, "MM")

If Mnth = "01" Then
txtErr.ControlSource = "WorkTrack.JanErr"
lblMonth.Caption = "Janurary"
End If
If Mnth = "02" Then
txtErr.ControlSource = "WorkTrack.FebnErr"
lblMonth.Caption = "February"
End If
If Mnth = "03" Then
txtErr.ControlSource = "WorkTrack.MarErr"
lblMonth.Caption = "March"
End If
If Mnth = "04" Then
txtErr.ControlSource = "WorkTrack.AprErr"
lblMonth.Caption = "April"
End If
If Mnth = "05" Then
txtErr.ControlSource = "WorkTrack.MayErr"
lblMonth.Caption = "May"
End If
If Mnth = "06" Then
txtErr.ControlSource = "WorkTrack.JunErr"
lblMonth.Caption = "June"
End If
If Mnth = "07" Then
txtErr.ControlSource = "WorkTrack.JulErr"
lblMonth.Caption = "July"
End If
If Mnth = "08" Then
txtErr.ControlSource = "WorkTrack.AugErr"
lblMonth.Caption = "August"
End If
If Mnth = "09" Then
txtErr.ControlSource = "WorkTrack.SepErr"
lblMonth.Caption = "September"
End If
If Mnth = "10" Then
txtErr.ControlSource = "WorkTrack.OctErr"
lblMonth.Caption = "October"
End If
If Mnth = "11" Then
txtErr.ControlSource = "WorkTrack.NovErr"
lblMonth.Caption = "November"
End If
If Mnth = "12" Then
txtErr.ControlSource = "WorkTrack.DecErr"
lblMonth.Caption = "December"
End If
[1911 byte] By [james3302] at [2007-11-20 10:53:21]
# 1 Re: Code works when stepping thru, but doesnt when running
Okay now its seems to work when I just run the form, but when I make it a MDE is doesn't work.

the MDB will work, but once I compile a MDE, the MDE and MDB no longer work, If I edit the code then it will work again. At least until I make the MDE.
james3302 at 2007-11-9 19:34:13 >
# 2 Re: Code works when stepping thru, but doesnt when running
Suppose you use this instead:

txtErr.ControlSource = "WorkTrack." & MonthName(Mnth, True) & "Err"
lblMonth.Caption = MonthName(Mnth)

So there would be no Select Case or If...Then.
You might also use Month(Date), if access provides it.
WizBang at 2007-11-9 19:35:17 >
# 3 Re: Code works when stepping thru, but doesnt when running
sounds great I will try it tomorrow while at work.
james3302 at 2007-11-9 19:36:15 >
# 4 Re: Code works when stepping thru, but doesnt when running
I tweeked the code and it works just like the other one did. I noticed that it will run until I make that DB a MDE then the MDE will not work nor the MDB. But thanks for the shortened code suggestion.
james3302 at 2007-11-9 19:37:15 >
# 5 Re: Code works when stepping thru, but doesnt when running
I got it to work. Heres the code, I basically took out the table name from the code.

Mnth = Format(Date, "mm")
txtErr.ControlSource = Format(Date, "mmm") & "Err"
lblMonth.Caption = Format(Date, "mmmm")
james3302 at 2007-11-9 19:38:25 >
# 6 Re: Code works when stepping thru, but doesnt when running
That's interesting. Does this mean you no longer need the Mnth variable?
WizBang at 2007-11-9 19:39:24 >