duplicate values error

snooper

Perch
Hi all

i am trying to do a simple addNew into a table - nothing special. it seemed to work a little while back, now suddenly i am gettimng the following error. i have even tried commenting out all the inserted fields, except for one at a time - and i still get the error - which leads me to believe that its not to do with any specific field (cos anyway there is only one primary key field which i dont touch).

any ideas?

thanks!



Microsoft JET Database Engine error '80004005'

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.

/office/groups/SubGroupsadd.asp, line 777
 
Yes - access it is.

In the end it was a problem in the Access Db. for some odd reason (Still to be found) - it would generate a autonumber thats already been used (!!!!) - really dont know how that could happen, even after a repair/compact. wierd!!!



doctorallia said:
I would recommend using an SQL string to insert rather than Addnew

How can i do this? with copying all fields of a record to a new row - except for changing one field value?
thanks
 
I would use a recordset to get the info on a record and then execute an SQL statement to insert a new record with the values from that along with the changed value. The format would be something like this:

INSERT INTO dbf_name [(FieldName1 [, FieldName2, ...])]
VALUES (eExpression1 [, eExpression2, ...])
 
read the old record and store the old values in variables then write to a new record.


edit: sorry Yash.. I must have hit add reply before you posted your reply.. so basically i said the same thing!
 
Back
Top