Recursion happening...

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
 
D

Dirk Goldgar

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top