Results 1 to 2 of 2
  1. #1
    dastr is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2012
    Posts
    8

    Query Criteria - capturing data in a certain format

    Hi all,

    in a query, I would like to capture data that is in the following format:
    123456 (6 digits) AND
    A12345 (1 letter and 5 digits) AND
    AB1234 (2 letts and 5 digits)

    The letter could only be at the beginning of the abbreviation.

    Do you have any suggestions?



    Thanks in advance.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    So any of the 3 configurations are acceptable entries? Could try an expression in the ValidationRule property or a VBA procedure in the BeforeUpdate event of textbox to valdiate the entry.

    x = field value

    Possible ValidationRule:
    IsNumeric(x) Or x Like "[A-Z]#####" Or x Like "[A-Z][A-Z]####"
    Then ValidationText property: Enter value in format of 123456, A12345, AB1234

    VBA something like:
    If Not IsNumeric(x) And Not x Like "[A-Z]#####" And Not x Like "[A-Z][A-Z]####" Then
    Cancel = True
    MsgBox "Invalid entry."
    End If
    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. data field in query twice based on criteria
    By sandyg in forum Queries
    Replies: 1
    Last Post: 09-29-2011, 07:47 AM
  2. Data type mismatch in query criteria
    By TinaCa in forum Queries
    Replies: 2
    Last Post: 09-19-2011, 11:31 PM
  3. Query Criteria Causing Data Mismatch Error
    By jrubenol in forum Queries
    Replies: 2
    Last Post: 09-14-2011, 09:34 AM
  4. Query: How To Filter Data In Criteria
    By netchie in forum Queries
    Replies: 1
    Last Post: 08-31-2011, 01:36 PM
  5. Replies: 6
    Last Post: 09-25-2009, 12:40 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