Restrict use of special charecters

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Shakss2
    New Member
    • Dec 2007
    • 19

    Restrict use of special charecters

    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
  • Zwoker
    New Member
    • Jul 2007
    • 66

    #2
    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?

    Comment

    • ADezii
      Recognized Expert Expert
      • Apr 2006
      • 8834

      #3
      Originally posted by Shakss2
      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:
      [CODE=vb]
      Private Sub txtInvoice_KeyP ress(KeyAscii As Integer)
      Select Case KeyAscii
      'do not allow a ', ", ?, or @ in the Text Box
      Case Asc("'"), Asc(""""), Asc("?"), Asc("@")
      KeyAscii = 0 'Cancel the Keystroke
      Case Else
      'allow Keystroke to be processed
      End Select
      End Sub[/CODE]

      Comment

      • Shakss2
        New Member
        • Dec 2007
        • 19

        #4
        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

        Comment

        • ADezii
          Recognized Expert Expert
          • Apr 2006
          • 8834

          #5
          Originally posted by Shakss2
          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.

          Comment

          Working...