Results 1 to 6 of 6
  1. #1
    causative is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2009
    Posts
    3

    do not allow duplicates with the error message without VBA? [ACCESS 2010]

    Hello,
    I input data each day to the simple query:

    ID, Date, Customer, Order_Number, Details, Customer&Order_Number

    How could I block with the error message, the move from Order_Number filed to the Details field if the concatenation of Customer and the Order_Number is a duplicate?



    Thx in advance

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    to use the standard access error message, create a multi field index in the table for customer and order number fields and set the allow duplicates property to no. But this will only work when the record is updated/created. Otherwise you will need to use VBA.

  3. #3
    causative is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2009
    Posts
    3
    Thank You, I have tested multi field index a minute ago and its some kind of good solution.
    One additional question, If I decided to write a VBA code is it able to show the msgbox in the table view during input the data or the form must be created at first?

  4. #4
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    You can't have VBA functions while entering data directly into a table. In fact, you shouldn't be allowing direct entry at all, tables should be hidden from users.

  5. #5
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    you can create a datasheet form which looks exactly the same as a query 'form' based on your query, then you can use vba in the order number after update event to check if the combination of customer and order number already exists, and if it does, take appropriate action.

    however you need to consider all possibilities - what if a user enters an order number before entering a customer for example?

  6. #6
    causative is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2009
    Posts
    3
    Thank You. I will consider it

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

Similar Threads

  1. Replies: 1
    Last Post: 07-26-2016, 06:34 AM
  2. Pop up Message on Duplicates Error.
    By Torinjr in forum Forms
    Replies: 11
    Last Post: 06-09-2015, 07:30 PM
  3. Damaged mdb 2010 file gives strange error message
    By sanchomosso in forum Access
    Replies: 2
    Last Post: 06-07-2015, 06:27 PM
  4. Replies: 6
    Last Post: 07-07-2014, 09:13 AM
  5. Replies: 2
    Last Post: 03-30-2012, 10:50 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