View Full Version : Limiting number of characters in an unbound textbox


RobS
07-13-2000, 10:57 AM
Is there a way to limit the number of characters one can enter into an UNBOUND textbox? Of course, if the textbox were bound to a field, the length of the field would limit the textbox. But what about a textbox that is unbound?

Travis
07-13-2000, 11:20 AM
Add this code to the Change Event of the unbound field.

Private Sub YourField_Change()
On Error Goto ErrorHandler
dim lFieldLength
lFieldLength = 10
if len(me.[YourField])> lFieldLength then
me.[YourField]=Left(me.[YourField],lFieldLength)
end if

Exit Sub
ErrorHandler:
msgbox Err.Number & vbcrlf & vbcrlf & Err.Description

End Sub