Results 1 to 6 of 6
  1. #1
    bassplayer79 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2013
    Posts
    18

    Data Validation for letters and numbers

    I'm getting the hang of Access and VBA. My app is just about complete now, and functioning quit well, really looking to test this thing out. This is also my first Access Database, so its kinda like my baby. Anyways, I'd like to add some data input validation. Right now if someone enter incorrect characters, it will return invalid Null. Id like to customize the error before it returns an error about a null value. So the part numbers will be PW001 - PW126. I know how to validate PW using IntStr, I'm just stuck on validating 001-126.

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Perhaps you could get the numeric part using Right() function and make it numeric by using Int() function. Then check for >0 and <126
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    bassplayer79 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2013
    Posts
    18
    Quote Originally Posted by Bob Fitz View Post
    Perhaps you could get the numeric part using Right() function and make it numeric by using Int() function. Then check for >0 and <126
    Its worth a shot! Though I'm not sure how it will handle 001. I cant take that out, that is part of the actual part number.

  4. #4
    bassplayer79 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2013
    Posts
    18
    How would format that?

  5. #5
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Perhaps something like:
    Int(Right([YourField],3))
    Last edited by June7; 09-16-2013 at 03:18 PM. Reason: fix type, missing ]
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,603
    Int() will drop leading zeros. So if they accidentally enter PW00001, this will not be caught. Perhaps you need to test the length of the number part as well as it is <= 126.

    What is purpose of the data entry? Are you creating a table of parts? Or is a part being input into say an order for parts? Why not use a combobox for users to choose parts from?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. mix of letters and numbers on the form
    By iscinar in forum Forms
    Replies: 15
    Last Post: 10-20-2013, 06:11 AM
  2. Add letters to sequential numbers
    By bassplayer79 in forum Programming
    Replies: 29
    Last Post: 09-12-2013, 04:20 AM
  3. Sorting by Letters and then numbers with dashes
    By Analogkid in forum Queries
    Replies: 8
    Last Post: 04-29-2013, 05:05 PM
  4. IIF with numbers and letters
    By hzrdc2 in forum Queries
    Replies: 2
    Last Post: 03-28-2013, 07:29 AM
  5. Removing all letters or all numbers from string
    By Hayley_sql in forum Programming
    Replies: 2
    Last Post: 09-16-2009, 02:01 AM

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