A family of Microsoft relational database management systems designed for ease of use.
I use this one
http://allenbrowne.com/ser-34.html
Work perfectly.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have a textbox name text36 and store the following example string
A-B
I want to prevent the user from entering more than 3 characters.
I try: Note i used Select case KeyAscii for event Keypress for 2 last one.
me.text36.maxlength=3 'does not work in new version
Or
Length1 = Len(Text36)
Text36.text = Left(Text36.text, Text36.TextLength - 1) 'also does not work
Or
'If Len(Text36) > 3 Then
'KeyAscii = 0 'Eg: A-BB It only works if i lostfocus and gotfocus
Full Code
Private Sub Text36_KeyPress(KeyAscii As Integer)
Dim Length1 As Integer
Select Case KeyAscii
Case 48 To 57 'integer
KeyAscii = 0
Me.FilterNameTest.Visible = True
Me.FilterNameTest.Value = "Numbers are not allowed"
Case 97 To 122 '[a-z]
KeyAscii = 0
Me.FilterNameTest.Visible = True
Me.FilterNameTest.Value = "Lower case alpha are not allowed"
Case 33 To 44, 46, 47, 58 To 64, 91 To 96, 123 To 126 'special characters
KeyAscii = 0
Me.FilterNameTest.Visible = True
Me.FilterNameTest.Value = "Special Characters are not allowed except -"
Case 65 To 90, 45
Me.FilterNameTest.Visible = False
'If Len(Text36) > 3 Then
'MsgBox ("Length too long")
'KeyAscii = 0
'Length1 = Len(Text36)
'Text36.text = Left(Text36.text, Text36.TextLength - 1)
'End If
End Select
End Sub
If the textbox was related to a record, we could just put a fix length for that field but it not the case, is there any option in the database to do this or code only. ??
A family of Microsoft relational database management systems designed for ease of use.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
The validation rule will give me an msg for using Len(Text36) and input mask works but is pretty difficult to use as the SelStart start from end and has an underscore.
Is there any other way to do it ??
Try a validation rule on the control to limit it to 3 characters. Or if the value is 2 letters on either side of a dash, then use an input mask