Recursion happening...

  • Thread starter Thread starter BobRoyAce
  • Start date Start date
B

BobRoyAce

I've got a text box, named txtDate, which has code associated with its
LostFocus event as shown below. When the control loses focus, this code is
entered as it should be. However, after the second code line runs (where
[Fiscal Week]'s value is set), the LostFocus event fires again. Just FYI,
[Fiscal Month] and [Fiscal Week] are both fields in the form's underlying
table which have invisible controls on the form that correspond to them. Why
does the LostFocus event keep firing?

--- CODE BEGINS ---

Private Sub txtDate_LostFocus()
[Fiscal Month] = DLookup("[Month Data]![System Month Number]", "[Month
Data]", "[Month Data]![Month Start Date] <= txtDate.Value And [Month
Data]![Month End Date] >= txtDate.Value")
[Fiscal Week] = DLookup("[Week Info]![WeekID]", "[Week Info]", "[Week
Info]![Start Date] <= txtDate.Value And [Week Info]![End Date] >=
txtDate.Value")
End Sub
 
BobRoyAce said:
I've got a text box, named txtDate, which has code associated with its
LostFocus event as shown below. When the control loses focus, this
code is entered as it should be. However, after the second code line
runs (where [Fiscal Week]'s value is set), the LostFocus event fires
again. Just FYI, [Fiscal Month] and [Fiscal Week] are both fields in
the form's underlying table which have invisible controls on the form
that correspond to them. Why does the LostFocus event keep firing?

--- CODE BEGINS ---

Private Sub txtDate_LostFocus()
[Fiscal Month] = DLookup("[Month Data]![System Month Number]",
"[Month Data]", "[Month Data]![Month Start Date] <= txtDate.Value And
[Month Data]![Month End Date] >= txtDate.Value")
[Fiscal Week] = DLookup("[Week Info]![WeekID]", "[Week Info]",
"[Week Info]![Start Date] <= txtDate.Value And [Week Info]![End Date]
= txtDate.Value")
End Sub

The only thing that occurs to me at the moment is that maybe you have
code in the form's Dirty event that moves the focus around, maybe back
to txtDate.
 
Back
Top