Results 1 to 4 of 4
  1. #1
    drcfire is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2012
    Posts
    2

    How to do a quick validation of a field on a form

    On our Order Entry form, the user will check a radio button for either Company1 (value = 1) or Company2 (value = 2). The next field they enter is the Customer Number. If they clicked on Company2, then the Customer Number they enter MUST end with a T....for example, the customer number might be MED03T (it's always 6 characters and it always ends with a T). If they clicked on Company 1, it CANNOT end with a T....for example, the customer number might be MED03. I am trying to put a verification in my form (presumably in the BeforeUpdate event of the CustomerNo field), but I don't know the syntax (all I'm really trying to do is give a message if it's wrong) It should go something like this...

    If Me.CompanyID = 1 and Me.CustomerNo = *T, then
    MsgBox "You've entered an incorrect customer number"
    .
    .
    .

    The 2 conditions that must be met are:
    1) If CompanyID = 1, then the CustomerNo must NOT end with a T
    2) If CompanyID = 2, then the CustomerNo MUST end with a T


    Thanks for any help....
    Darrell

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You are going to use functions like Len() and Right()

  3. #3
    drcfire is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2012
    Posts
    2
    Thanks, RG, using the Right() function was exactly what I needed.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Excellent! Thanks for posting back with your success.

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

Similar Threads

  1. Validation rule for a month field
    By Alliana Gray in forum Access
    Replies: 7
    Last Post: 08-11-2011, 12:41 PM
  2. Data Validation of another field
    By dssrun in forum Access
    Replies: 4
    Last Post: 03-22-2011, 01:09 PM
  3. BUG! Field level date validation
    By buj in forum Forms
    Replies: 0
    Last Post: 09-16-2010, 08:23 PM
  4. Form Field Validation
    By dhav79 in forum Forms
    Replies: 3
    Last Post: 06-03-2010, 11:31 AM
  5. Quick way to stuff field names into text field
    By kfinpgh in forum Programming
    Replies: 0
    Last Post: 01-04-2007, 01:13 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