Importing into Access existing DB with autonum PrimaryKey

  • Thread starter Thread starter Michael
  • Start date Start date
M

Michael

I am having troubles trying to import a comma delimited
text file into an existing database. The database uses a
primarykey set to autonum. When trying to import there is
an error becuase the field i have for the key is blank. I
do not want to prenumber these entries because i want to
be able to add onto where the other database left off.
Any help as to what to put in the key field in my text
file would be great. Thank you.
 
Michael,

I believe that, if you do not define the primarykey field,
in your import of the data, the system will do what you
want/need -- number the entries being added, consecutive
to entries that already exist in the database. Your
including a blank field for a key is causing the problem.
Drop the key field from your import definition, and the
entries should import correctly.
 
Thanks for the suggestion but that did not work. By
dropping off the key field it just tried to put the next
fields data in the keyfield. If anyone else has any
suggestions as maybe a character or anything that would
allow the autonum to keep working please let me know.
Thank you
 
Here's one way: Import the CSV file(s) into a staging table and then append the staging table's contents to your table of choice. For example, suppose you wanted to import MyData.csv into tbd_MyData, which has the AutoNumber primary key you mentioned. Instead, import the CSV file(s) into tbd_MyDataStaging, which is identical to tbd_MyData except it doesn't have the AutoNumber field. Then run a query to append tbd_MyDataStaging's contents into tbd_MyData. (And maybe run a delete query to empty tbd_MyDataStaging, to prep it for the next time you import.)
 
Thank you, This method did work. As much of a pain it was
it did in fact get the job done and i thank both of your
for your help and suggestions.

-----Original Message-----
Here's one way: Import the CSV file(s) into a staging
table and then append the staging table's contents to
your table of choice. For example, suppose you wanted to
import MyData.csv into tbd_MyData, which has the
AutoNumber primary key you mentioned. Instead, import the
CSV file(s) into tbd_MyDataStaging, which is identical to
tbd_MyData except it doesn't have the AutoNumber field.
Then run a query to append tbd_MyDataStaging's contents
into tbd_MyData. (And maybe run a delete query to empty
tbd_MyDataStaging, to prep it for the next time you
import.)
 
Back
Top