Results 1 to 3 of 3
  1. #1
    USAFA2012 is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    1

    Setting a field to only accept text characters, not numbers


    I'm trying to set up a database for a school project. My instructor loves to go into random fields and type garbage in an input field and see if the system stops him (ie "3401" for the "Name" field).

    I've tried 15 different validation rules all based on NOT <0, NOT >0, NOT = 0. Nothing works. I would think just setting the field to "Text" in Design view would do it, but I guess that makes too much sense.

    Does anyone know how to do this? This is the last bit of table formatting I have to do before I do the relationships (which I know how to do), add in my records (through forms), set up forms, queries, etc.

    HELP A NOOB OUT!!!PLZ!!!!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    There may be a way to do that at the table level, but the easiest way I can think of would be to use the KeyPress event of the form control used to enter the data. Test the KeyAscii value against the allowable characters, and only let through those you want to allow.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Stressed is offline Novice
    Windows XP Access 2003
    Join Date
    Mar 2010
    Posts
    19
    Quote Originally Posted by pbaldy View Post
    There may be a way to do that at the table level, but the easiest way I can think of would be to use the KeyPress event of the form control used to enter the data. Test the KeyAscii value against the allowable characters, and only let through those you want to allow.
    Here is a snipit that I use.

    Code:
    If KeyAscii = 127 Or KeyAscii = 8 Then
    Else
        If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0
    End If

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 12-15-2009, 01:47 PM
  2. Setting Field Properties for Numbers
    By Tim Hardison in forum Access
    Replies: 1
    Last Post: 12-09-2009, 06:47 AM
  3. How to make a field accept No spaces
    By jhjarvie in forum Forms
    Replies: 4
    Last Post: 09-26-2009, 04:10 PM
  4. Setting a field to be dependent on another
    By CushingMT in forum Forms
    Replies: 0
    Last Post: 11-19-2008, 11:51 AM
  5. Extract numbers from text string strored in a field.
    By khabdullah in forum Programming
    Replies: 2
    Last Post: 12-23-2007, 06:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums