Duplicate Entry Question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a simple "Add Customer" form. It has a txtbox with "CustomerID". It is
bound to the table "Customer". The user inputs the unique ID. This is a
primary key "Text", with No Duplicates selected. There are also other
txtboxes for Name, etc. This form also has a combo box used to display
customer names so they can be edited, using the same txtboxes. My problem:
When I add a new customer, the program allows duplicates, even though I have
set No Duplicates in the table.
Sure would appreciate some help. Thanks
 
I found that if you "Tab" your way thru the boxes it works fine. I was adding
multible customers and used the navagation ">". Now I have to figure how to
keep a user from doing that.
 
I have a simple "Add Customer" form. It has a txtbox with
"CustomerID". It is bound to the table "Customer". The user inputs the
unique ID. This is a primary key "Text", with No Duplicates selected.

There are also other txtboxes for Name, etc. This form also has a
combo box used to display customer names so they can be edited, using
the same txtboxes.

My problem: When I add a new customer, the program
allows duplicates, even though I have set No Duplicates in the table.
Sure would appreciate some help. Thanks

I don't understand this last bit. If you have a unique index on the
CustomerID field, then the db engine will not allow two records with the
same value. Are you sure that the values are the same?- remember that
"Eric" is not the same as "Eric " and so on. Are you sure that the
records are being saved in the table? Are you able to enter records with
duplicate CustomerID directly in the table datasheet?

Having said that, it's customary to get the form itself to check on
uniqueness, because the error message from the db engine is not very nice
for users. Googling on this group will show you lots of examples of using
the BeforeUpdate event to prevent duplicates.

Best wishes


Tim F
 
Yes, the the duplicate records are being saved to the table and they are
exact duplicates. I will look to google and try to figure this out. When I
input the records directly into the table, it works. Thanks for your response.
 
Yes, the the duplicate records are being saved to the table and they
are exact duplicates.

In that case, you don't have a unique index. To see what is going on, look
at the table in design mode and open the indexes window: use the menu View
-> Indexes or click the toolbar button with the lightning on it. You should
see an index with your one field on it, and a setting of Unique Yes below
it.

If you have a compound index, then of course you can have the same value in
one field as long as the values in the other one(s) differ.
When I input the records directly into the table, it works.

What works? The records are stored, or they are rejected?

Tim F
 
Tim
This is the craziest thing I have seen. While checking this out, I
discovered that some of the customers numbers "text" could be duplicated
while others could not be duplicated directly in the table. Those that could
be duplicated, I re-entered them and now they are all working, NOT allowing
duplicates. Also I found some great "beforeUpdate" event code that corrects
the duplication problem at the form level on google as you suggested. Thanks
for your help.
 
This is the craziest thing I have seen. While checking this out, I
discovered that some of the customers numbers "text" could be
duplicated while others could not be duplicated directly in the table.

May well be space characters that you can't see. "983 " will look the same
as "983" in a text box. One reason for using Number types for numbers
rather than text types.
"beforeUpdate" event code that corrects the duplication problem at the
form level on google as you suggested. Thanks for your help.

Glad it worked out for you. All the best


Tim F
 
Back
Top