Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a validation method for user form textbox ?

Status
Not open for further replies.

OscarPCG

Technical User
Aug 12, 2004
15
US
Is there a validation method for user form textbox?
I would like to restrict data entered into a text box to numbers or letters only (depending on the textbox)?

Thanks
Oscar
 
Oscar,
I'm not an MVP but couln't you use a
Private Sub Txtbox3 After_Update
Loop until ISNUMERIC(Txtbox3.Value)=True
MsgBox "Enter a number dumby!",Vbokonly,"Stupid Person"
Txtbox3.Value=""
Cancel=True
Txtbox3.SetFocus
Do
End Sub

Just a thought
One of the MVPs probably have a better idea.

Thanks, Rib

Bartender:Hey aren't you that rope I threw out an hour ago?

Rope:No, I'm a frayed knot.
 
Hi Oscar,

There is no built in validation but there are several events where you can code your own - BeforeUpdate is the usual event for validation.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at [url=http://www.vbaexpress.
 
Generally the validation rules are enforced in the BeforeUpdate event procedure of the control, so you can play with the Cancel variable.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks guys! This is exactly what I was looking for.

Oscar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top