importing & autonumbering of primary keys

  • Thread starter Thread starter nChicago
  • Start date Start date
N

nChicago

I would like to import a text file into a table.
The first record has a primary key of autonumber (no dupes).

How do I import the file without hardcoding PK's via the input file?

Access does not seem to allow importing the records without a value, I'm
concerned there will be a future problem with the autonumber function
duplicating PK values.

any advice appreciated.

Thanks.

N
 
I can't quite visualize your problem.

You can have and Index that does not allow duplicates and an autonumber. If
you have an externally generated primary key, then you may not need the ID or
autonumber.

When importing a space delimted txt file where I want to have an autonumber
I moove the ID or autonumber to the last field in the table. In that way
even a copy and paste will work. Ttext. ID

I use an update query to update recrords and append new records to maintian
my primary keys, yet update new information from a third party non Access
report where the third party report is more current than my Accesss. But I
need SQL access to the data and with a primary key to eliminate duplicates.
 
I would like to import a text file into a table.
The first record has a primary key of autonumber (no dupes).

How do I import the file without hardcoding PK's via the input file?

Access does not seem to allow importing the records without a value, I'm
concerned there will be a future problem with the autonumber function
duplicating PK values.

If your Text file does not contain anything in the primary key field,
you can simply use File... Get External Data... Link to link to the
text file, and run an Append query to populate the other fields. The
autonumber will work normally (possibly leaving a gap).

If your text file *does* contain numbers in this field, then an Append
query appending these numbers into the autonumber field will work.
Future duplicates (from future imports) might be a problem, but the
Autonumber will take off from one more than the largest value
imported.

John W. Vinson[MVP]
 
Thanks, John.
And if I just do an import with the PK values hard coded (numbers), will the
sequential number generator still start at 1 for new records or will it look
up the max value in that field and use it as a starting pont?

Regards,

N
 
Thanks, John.
And if I just do an import with the PK values hard coded (numbers), will the
sequential number generator still start at 1 for new records or will it look
up the max value in that field and use it as a starting pont?

It will look at the max. It may be best to Compact the database after
importing and before entering new data. As a rule, you shouldn't trust
Autonumber to create human-meaningful values - there will always be
gaps in an Autonumber field, not just deleted records, but those where
the user started to enter a record and cancelled the addition.

John W. Vinson[MVP]
 
Back
Top