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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please help with data vaildation of text box Access VBA

Status
Not open for further replies.

vamoose

Programmer
Oct 16, 2005
320
MX
I have a form with multiple data entry text boxes. The one in particular is named Stack_height with a control source of Stack. I would like to limit the input of this text box to 0.70 thru 6.0 general numbers. If anything other than this range or null is entered I am trying to clear contents of stack_height and set focus again to stack_height and display a msgbox with helpful information. I am trying to do this within Access VBA using the lost focus event. I can't seem to accomplish this. Please reply with any suggestions. Thanks so much.
 
can't you set a validation rule at database level ?
or are these boundaries likely to change ?
 
Use the BeforeUpdate event of the control and the Cancel parameter instead of the LostFocus event and the SetFocus method.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
How do you vaildate a null in the text box?
isnull[stack], [stack] is null, [stack]="" all do not work, it lets you tab out of the text box on to the next.
 
If Trim(Me![stack] & "") = "" Then
MsgBox "[stack] is either null, blank or zero length"
End If

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top