Results 1 to 3 of 3
  1. #1
    blacknblue is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2012
    Posts
    1

    BeforeUpdate compare two fields on same record

    Hello,

    I'm trying to prevent an update to a record if a three digit code in the center of a compressor model number does not match the first digit of a unit model number.



    For example:

    Unit model number F054VHN = Compressor model number ZP103KCE-TF5-455

    I've attached my database. Thank you very much in advance.
    Attached Files Attached Files

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    I can't read 2007+ databases.

    If you are checking a specific character for a specific value you can use the MID function

    So let's say on your form:

    MODELNUMBER is your F054VHN
    COMPRESSORMODEL is ZP103KCE-TF5-455

    if you are trying to see if the 11th character of COMPRESSORMODEL is equal to the first character of the MODELNUMBER

    you would have to set up something in the BEFORE UPDATE event something like

    Code:
    if left([MODELNUMBER],1) <> mid([COMPRESSORMODEL],11,1) THEN
        Msgbox "Model Number Mismatch"
    endif

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by blacknblue View Post
    ...if a three digit code in the center of a compressor model number does not match the first digit of a unit model number.
    How can a three digit code ever match a single digit?
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Compare two fields
    By funkygoorilla in forum Programming
    Replies: 2
    Last Post: 01-18-2012, 09:43 PM
  2. Replies: 3
    Last Post: 11-23-2011, 12:25 AM
  3. SELECT WHERE compare two fields
    By bulb763 in forum Access
    Replies: 5
    Last Post: 03-22-2011, 09:56 AM
  4. Using IIF to compare two fields data
    By psych in forum Access
    Replies: 2
    Last Post: 03-10-2010, 10:11 AM
  5. Compare two fields!
    By finditsol in forum Forms
    Replies: 1
    Last Post: 02-11-2010, 01:43 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