Restrict Characaters in a text box

Benwatson

Registered User.
Local time
Today, 11:02
Joined
Oct 11, 2016
Messages
26
So i have a text box called Description. this is the only text box in which they would add alphabetical characters. if they where to put an incorrect character such as a ' then i would stop the macros that sends the data to a table :/

i need a way of restricting such characters

any ideas please
 
You can also handle the KeyPress event, and for selected characters, change the value of the keyascii parameter, like...
Code:
Private Sub Text5_KeyPress(KeyAscii As Integer)
    Select Case Chr(KeyAscii)
        Case "0" To "9", "'", """"
            KeyAscii = 0
    End Select
End Sub
...so that simply cancels all numbers and quotes.
 
mark-Thanks that worked a treat

steve- was unable to work the input mask but thanks for the suggestion
 
I don't believe the KeyPress event is fired when someone pastes data into a textbox so you might want to supplement MarkK's code with beforeupdate code that checks the input for invalid characters.
 

Users who are viewing this thread

Back
Top Bottom