Problem in Setfocus Method

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi,
in my form there is a textbox named txtEid ..if the user give either null
or invalid eid , a message box popups..after that the focus must goto the
textbox itself...the problem is its not focusing to the textbox...

here is the code am using

if isnull(txteid) then
msgbox "Enter the employee ID"
txteid.setfocus
exit sub
endif

Please help me to get out of this problem....

Thanks in advance...

with best regards

sunil.T
 
Hi,

On which event are you running this?
Best to take the afterupdate event.
If this is the case or it still does not work then you could try to just
set the focus first to another field on the form and then back to txteid.

- Raoul
 
Your validation should be done on the BeforeUpdate event for the textbox.
That way, if an invalid entry has been made, you can cancel the event and
the focus stays on the textbox.

If you want to do this as a "final" validation, before the form saves the
data, then use the form's BeforeUpdate event, cancel that event, and set
focus to the textbox.
 
Back
Top