Unable to import from Excel into table with Multiple-field primary key

pdeleeuw930

New member
Local time
Yesterday, 22:02
Joined
Jul 12, 2012
Messages
3
Hi folks,

I am learning Access by doing and may have missed some important theoretical point.

I have a table in my database that contains sets of lumber prices from different time periods. Any given size of lumber comes in several grades and different grades have different prices.

A complete set of prices consists of a price for each Size/Grade combination. My table is to contain a growing number of complete price sets each associated with a date.

So my fields are these: DateTime (a date/time field), SizeName (text 10), GradeGroup (text 10), and Price (Double).

None of the fields alone would serve as a primary key but each combination of DateTime/SizeName/GradeGroup will be unique. Accordingly I assigned those three fields as being the primary key.

When I try to import this historical data from an excel spreadsheet which contains one price set, everything looks like it's going well. It correctly interprets my column headings, etc.. But when I push the "Finish" button it complains that it is rejecting 72 records (that would be every single one of them) because the key is not unique.

I have stripped this table of its relationships to other tables but the symptom remains the same. The table is empty as I do the experiment so there's no chance of a duplicate already in there. If I say "Go ahead anyway", it imports all the price records into their correct fields and every Date/Size/Grade combination is indeed unique.

What am I missing in my inexperience? Grateful for any ideas!
 
I would add an autonumber field to your table and use that as the PK. Import the data from the spreadsheet and Access will automatically populate the PK.
 
This is great. I'll try it. Thanks also for the advice on data type. I have adopted it.
 

Users who are viewing this thread

Back
Top Bottom