Return to textbox

  • Thread starter Thread starter Gib
  • Start date Start date
G

Gib

I have a Textbox that an entry is made. Once entry is
made and focus is lost, a few lines of code are activated
to verify entry. If entry fails, message is displayed and
text is cleared.

How do I position the cusor back on this text box
when "OK" is used on the message box.

Thanks
 
Use the Me.MyTexBox.SetFocus.
BTW, this and similar questions you can easily find the answer to by using
the Object Browser.
In the VB editor, select View/Object Browser. Select TextBox and you will
get a list of all the properties and methods for a textbox.
If you select one and hit the F1 key, VB help will open with a description
of what you selected.

Ragnar
 
You did not mention which Event you use to run the code but for Field
validation, the TextBox_BeforeUpdate Event is usually the most suitable.

You can check the data entry in this and if required, set the Cancel
argument to True which will leave the Focus on the TextBox.
 
Back
Top