LostFocus can't return to control (1 Viewer)

jnh

Registered User.
Local time
Today, 05:21
Joined
Jan 2, 2012
Messages
31
Hi,

When a Control encounters 'LostFocus' it triggers a macro event. The macro performs a small test and displays a Error message, if so needed.
I want to go to next control if data is ok (which works) or I want to return to control where incorrect data was entered (LastName in example). Problem seems to be that it will not return to that control unless I force it to go to another control first. Can anyone explain. Thank you for any assistance...jnh

Macro:

Macroname: Condition: Action: Arguments:

test1 Len([LastName])<10 MsgBox Error msg details
... gotoControl [Lastname]
... cancelEvent

Above goes to next control in Form. Note that if I change [LastName] to
any other control in Form it will go there without any problem.
I have changed macro as follows (BUT there must be a better way):


Macroname: Condition: Action: Arguments:

test1 Len([LastName])<10 MsgBox Error msg details
... gotoControl [Firstname]
... gotoControl [Lastname]
... cancelEvent

Seem to be unable to include proper spacing in examples above.


One more: Is the cancelEvent needed/required ?
 

boblarson

Smeghead
Local time
Today, 05:21
Joined
Jan 12, 2001
Messages
32,059
Don't use the Lost Focus event, use the Control's Before Update event for validating and then issue a Cancel = True to stop the update from happening and it will also stop the move to another field. You can use the After Update event to send it to specific control if it needs to be.
 

Users who are viewing this thread

Top Bottom