Working with text boxes!!

  • Thread starter Thread starter Eqbal Vkilzadeh
  • Start date Start date
E

Eqbal Vkilzadeh

Hi,

I have created a form in which there are three textboxes. I have added
some conditions to these textboxes which are triggered by exit event. Now
when the user enters a wrong data into the textbox a message box pops up
and instructs the correct info that should be entered into the box.
Everything seems well so far, unless what I need to happen next is the
contents the textbox in which we have the incorrect data to be selected
and the user wouldn’t have to do it by pushing some extra unnecessary key
strokes. I thought by setfocus property this could be done. But it did not
work. Now could anyone tell me if there is an alternative way.

TNx,
eqbal
 
Hi
try
with me.textbox1
..setfocus
..selstart=0
..sellength=len(.value)
end with
 
Eqbal,
Try this

Private Sub TextBox1_exit(ByVal Cancel As MSForms.ReturnBoolean)
If TextBox1 <> "Your condition" Then
MsgBox "Incorrect Data Entered" & vbLf & "Please Try Again"
Cancel = True
With TextBox1
.SelStart = 0
.SelLength = Len(.Text)
End With
End If
End Sub

Neil
 
If you only have one textbox in an userform, why is it necessary to als
install a command button and put any error testing in the private codin
for the command button?

If you have two or more textboxes in an userform, is it necessary t
have a command button, also?

Chuckles12
 

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

Back
Top