Prevent duplicate record from being written to a table
I have a datasheet form that has 5 fields. If the user double clicks the record selector the record is written to a separate table. But if the user d/c again and that record has already been written to the table I don't want to allow it if it is an exact duplicate (all 5 fields). How can I prevent this from being allowed?
Gustav, I think I did what you suggested. I went to the design of the table, indexes, and added all 5 fields and made them Unique = Yes. It worked. Did I do exactly what you suggested?
Also, is there a way to let the user know the record couldn't be added because it already exists?
Yes, that's it.
But to play nicely, you'll have catch the error when trying to insert the record and, if so, pop a normal messagebox to inform the user politely.
Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.