G
Guest
Sorry F/folks - I'm an SQL novice
I'm trying to write a small bit of SQL to append records to a table in
Access2000. I have data held in a staging table and I want to append too all
fields but one (the primary key - an autonumber field) to the main table
I know it could be done by including all the other fields but I want this
piece of code to be usable for all my tables and all my tables use the same
field name for their primary key.
This is what I have so far but it fails I think due to trying to copy a
number onto an autonumber key field (I get a message saying Changes not
successful due to duplicate key values)
strSQL = "INSERT INTO tbl" & strCurrentTable & " SELECT staging_tbl" &
strCurrentTable & ".* FROM staging_tbl" & strCurrentTable & " WHERE lngKey="
& lngCurrentKey
CurrentDb.Execute strSQL, dbFailOnError
If my primary key is called lngTableKey how would I change this code to
append everything except lngTablekey
Thanks in advance
Simon
I'm trying to write a small bit of SQL to append records to a table in
Access2000. I have data held in a staging table and I want to append too all
fields but one (the primary key - an autonumber field) to the main table
I know it could be done by including all the other fields but I want this
piece of code to be usable for all my tables and all my tables use the same
field name for their primary key.
This is what I have so far but it fails I think due to trying to copy a
number onto an autonumber key field (I get a message saying Changes not
successful due to duplicate key values)
strSQL = "INSERT INTO tbl" & strCurrentTable & " SELECT staging_tbl" &
strCurrentTable & ".* FROM staging_tbl" & strCurrentTable & " WHERE lngKey="
& lngCurrentKey
CurrentDb.Execute strSQL, dbFailOnError
If my primary key is called lngTableKey how would I change this code to
append everything except lngTablekey
Thanks in advance
Simon