Button to import Excel into two Access tables

  • Thread starter Chris via AccessMonster.com
  • Start date
C

Chris via AccessMonster.com

I have a button on my form to import an Excel sheet. I'm using
transferspreadsheet method. In Excel, row A:3 through E:3 should go into
tblMain. But row F:3 through J:3 should go to tbladdr.

How do I code Access to import into the two tables and keep the relationships.
The names on tblMain with a autonum will need to match the tbladdr import..

The Excel is a contact spreadsheet that the user is doing data entry. A-E
is the name info, and F-J is the address area. I need to capture the data
entry into the Access tables so that they link to each contactID which is an
autonum in Access. I thought to import and append to the tables, but how do
I keep the relationships?

I'm lost, can anyone help me here?

Thanks.
Chris
 
R

Ron2006

One way - Not nice but will probably work.

1) import A:3 thru J3 into a single stand alone table that you empty
before the import.

2) create an append query to the table holding A3 thru E3

3) create a separate append query for the other table that
appends to table 2 for every record between table 1 and the
importtable that matches all columns for the fields that were just
appended to table 1
You will therefore have all the fields you need to append to table 2 -
Addr infor from the importtable and ID from the table 1 record that
matches.

Now for the bad news
What if there already exists a record for contractor that matches
columns a3 thru E3?
If that did happen and you already have an address for that contractor
what do you want to do with the address data you just imported?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top