Duplicates in Table after adding data through a form

noobmaster

New member
Local time
Today, 07:10
Joined
Sep 2, 2019
Messages
5
Hello,

I have been facing some problems after adding data to a form which will update my table.

Every time I make an entry, there will be a duplicate in the table, which I dont want.

I have already set all fields index's to "No", and there is no primary key.

Do help, thank you!
 
Why have you removed indexes and the primary key?

All tables need a PK field.
Add indexes set to No duplicates for any fields you do not want duplicated.
 
Why have you removed indexes and the primary key?

All tables need a PK field.
Add indexes set to No duplicates for any fields you do not want duplicated.

Hi, thanks for the reply,

After adding a PK and editing the Indexes,
I have an error message "Run Time Error 3022: The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again."

Not sure where I am going wrong now...
 
FYI

I am using this VBA code to update the table through a form

Dim strSQL As String

strSQL = "INSERT INTO Product(ProductName, ProductQty, ProductSupplier, MinimumStk, ProductLocation, ProductShelf, ProductDrawers, ProductUnit) VALUES ('" & Me!ProductName & "','" & Me!ProductQty & "','" & Me!Combo120 & "','" & Me!MinimumStk & "', '" & Me!Combo140 & "','" & Me!ProductShelf & "','" & Me!ProductDrawers & "','" & Me!ProductUnit & "')"
DoCmd.RunSQL strSQL

End Sub
 
Only add no duplicate indexes where appropriate..not on all fields.
For example, if you don't want ProductName duplicated, that should be indexed.
But if you will ever reuse the same supplier or quantity etc, then duplicates for those fields must be allowed.
Fields that you will use for searches and filters can also be indexed but allowing duplicates.

EDIT
I've deleted your duplicate thread on the same topic
 

Users who are viewing this thread

Back
Top Bottom