By Richard Rost 12 months ago
Prevent Duplicate Products or Services in an Order
In this video, I'm going to show you how to prevent your users from adding a duplicate product or service to a customer's order in your Microsoft Access database, using something called a Composite Key.
Ramiro from Houston, Texas (a Platinum Member) asks: I run an auto detail shop. My database is pretty simple. We have about ten services that we provide. The problem is that sometimes one of my guys accidentally adds the same service twice, which should never happen. Is there a way to prevent this in the database?
In the video I mention that you cannot index Long Text fields. This used to be the case in older versions of Access. As of 2022, you can index Short Text, Long Text, Number, Date/Time, AutoNumber, Yes/No, and Hyperlink fields. You cannot index any of the field types that you shouldn't be using anyways: OLE Object, Calculated, Attachment. In older versions of Access you didn't used to be able to index Memo fields, which are now called Long Text fields, or Hyperlink fields. Honestly, I almost never index Long Text as that's going to be a real performance hit on your database.
Members will learn a different method to prevent duplicates. We'll use a little bit of VBA and the DCount function to check if the product is already on the order. If so, we'll ask the user if they want to add it or not. This also allows us to use a custom warning prompt instead of the default system message.
Silver Members and up get access to view Extended Cut videos, when available. Gold Members can download the database template from class plus get access to the Code Vault. If you signed up on YouTube you have to register on my YouTube Find User page so I can set up your account here on my web site. If you're not a member, Join Today!
microsoft access, ms access, ms access tutorial, #msaccess, #microsoftaccess, #help, #howto, #tutorial, #learn, #lesson, #training, #database, composite key, prevent duplicates, prevent duplicate entries, How do you prevent duplicate entry in Access, Preventing Duplicates from being entered, Preventing Duplicate Records Across Multiple Fields, How to Prevent a Duplicated Data Entry, vba code to prevent duplicate entries in access, sql how to prevent duplicate entries, ms-access check for duplicates before update, how to avoid duplication of data in database
Subscribe to Prevent Duplicates
Get notifications when this page is updated
Check out these other pages that may be of interest to you: