Return to textbox

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
 
R

Ragnar Midtskogen

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
 
V

Van T. Dinh

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.
 

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