>>Sarah:
>>
>>Have you tried GotFocus and LostFocus instead of When/Valid? InteractiveChange method is also good for keystroke-by-keystroke testing to change properties of other objects like command buttons, etc.
>
>Showing my 2.6 habits am I? I've had to to achieve some bits in my code but am not sure what the pros & cons of the two approaches are. Can you enlighten me?
>Sarah
I use GotFocus as a *replacement* for the When clause because it is code I want to fire when an object (e.g., a textbox) as soon as a user enters that object.
I use LostFocus if I want to validate the data when a user wants to leave an object (e.g., textbox). If the data is invalid, I can issue the following:
=MessageBox("Some appropriate user-error message")
NoDefault
This.SetFocus()
Return 0
You can also include code in either to enable/disable other form objects. I use InteractiveChange to do this as well on a login form. Once the UserID and Password textboxes have at least 1 character in them I enable the OK button. I just check the length of the .Value property of each in the InteractiveChange method in both.
I am going to post a new thread on a Calendar ActiveX control this morning about a gotcha I found about when a LostFocus firing after a click event of another control.
Mark McCasland
Midlothian, TX USA