Results 1 to 3 of 3
  1. #1
    Mister-B is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Posts
    31

    Don't save if record exists

    Hi there,

    I use a pretty substantial form (frmDaten) to enter data to a table. I wuld like to build some type of data checker into the form while data is being added to see if a new record being added already exists. If Fields 1 to 4 match up with an existing record, I would like a message to pop-up informing the user that the record already exists. I would also like for the new record not to be saved and the icing on the cake would be for Access to jump to the already existing record. Can anybody help?

    Kind regards,
    Martin

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Could have code associated with each of those 4 controls AfterUpdate event that looks for the combination of values in table. Use DLookup() domain aggregate expression and If Then Else conditional structures.

    Hard to be specific without knowing your db.
    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.

  3. #3
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    Create a unique index for the 4 fields so that duplication is not possible.
    Access will then block any duplicates and popup a message indicating where the data entered would result in duplication.
    If you don't like the standard Access message, you can create your own to replace it.

    You could then ask the user if they want to view the original record.
    If so, use a DLookup function to get the PK value for the record matching the four values in the index and open the form to that record.
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

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

Similar Threads

  1. Replies: 4
    Last Post: 12-14-2012, 06:33 PM
  2. Replies: 3
    Last Post: 10-19-2012, 04:30 PM
  3. Replies: 3
    Last Post: 10-08-2012, 08:40 AM
  4. Replies: 8
    Last Post: 09-27-2012, 11:12 AM
  5. Goto Record when Duplicate Record Exists
    By rlsublime in forum Programming
    Replies: 13
    Last Post: 03-22-2012, 03:46 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