By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,081 Members | 2,118 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,081 IT Pros & Developers. It's quick & easy.

Restrict use of special charecters

Shakss2
P: 19
Hello,

I have a text box where I enter a name.
I want to restrict the users from using a ' symbol or " symbol or any other special charecter in that text box.

How can I achieve it?

its access FE and BE.

Thanks

Shaq
Feb 11 '08 #1
Share this Question
Share on Google+
4 Replies


Zwoker
P: 66
This may be a too simplistic answer, but why can't you use an input mask and only allow normal A-Z and a-z characters?
Feb 12 '08 #2

ADezii
Expert 5K+
P: 8,638
Hello,

I have a text box where I enter a name.
I want to restrict the users from using a ' symbol or " symbol or any other special charecter in that text box.

How can I achieve it?

its access FE and BE.

Thanks

Shaq
If you want to allow only Alpha, Numeric, or AlphaNumeric characters, use an Input Mask as indicated by Zwoker. If you wish to disallow specific characters, you can trap the Keystrokes in the Control's KeyPress() Event. As an example, the following code will not allow a ', ", ?, or @ character in an Invoice Number Field:
Expand|Select|Wrap|Line Numbers
  1. Private Sub txtInvoice_KeyPress(KeyAscii As Integer)
  2. Select Case KeyAscii
  3.   'do not allow a ', ", ?, or @ in the Text Box
  4.   Case Asc("'"), Asc(""""), Asc("?"), Asc("@")
  5.     KeyAscii = 0  'Cancel the Keystroke
  6.   Case Else
  7.     'allow Keystroke to be processed
  8. End Select
  9. End Sub
Feb 12 '08 #3

Shakss2
P: 19
Hey,

Thanks a lot... that worked exactly the way i wanted it.

I have another post in this forum which was not answered yet.
"Excel report using old version of MS excel"

If you have a chance then pls look at it.

Thanks again.

Shaq
Feb 12 '08 #4

ADezii
Expert 5K+
P: 8,638
Hey,

Thanks a lot... that worked exactly the way i wanted it.

I have another post in this forum which was not answered yet.
"Excel report using old version of MS excel"

If you have a chance then pls look at it.

Thanks again.

Shaq
You are quite welcome, when I get a chance I'll have a look.
Feb 12 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.