Solved

Loading Data from Excel

Posted on 2011-03-11
1
291 Views
Last Modified: 2013-11-05
I have the following database (see screenshot: data model), I need to import the following data (see screenshot: excel data).

I need to import the data from the excel spreadsheet, but the audit columsn (C thru H) are actually their own records.  How do I go about indicating that each Audit creates it's own record.  Example first employee's data:

Employee ID 58468
Employee Marie Sampson

She should have 6 individual records in the tblPace

Audit 1
01/01/2010 in the "auditdate" field of tblPace
12 in the "pace" field of tblPace

Audit 2
02/01/2010 in the "auditdate" field of tblPace
14 in the "pace" field of tblPace

Audit 3
3/01/2010 in the "auditdate" field of tblPace
8 in the "pace" field of tblPace

Audit 4
04/01/2010 in the "auditdate" field of tblPace
13 in the "pace" field of tblPace

Audit 5
05/01/2010 in the "auditdate" field of tblPace
15 in the "pace" field of tblPace

Audit 6
06/01/2010 in the "auditdate" field of tblPace
14 in the "pace" field of tblPace

I need to do this for each row in the excel file.
ee-pacemodel.jpeg
ee-pacedata.jpeg
0
Comment
Question by:gcgcit
1 Comment
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 35107798
You cannot do this directly through the Import feature. You'll have to import the data to a Temporary table in Access, then use VBA/SQL to move the data into tables as needed. Basically, once you import the table, you'd build a recordset based on that imported table, loop through the records, and add them to the "live" tables as you go:

Dim rst As DAO.Recordset
Set rst = Currentdb.Openrecordset("SELECT * FROM MyTempTable")

Do Until rst.EOF
  '/check to see if the Employee exists:

  If Nz(Dlookup("EmployeeID", "Employees", "EmployeeID=" & rst("Employee"), 0) <> 0 then
    '/does not exist - add the Employee
  Else
    '/employee does exist
  End If

  '/add audit data
  Currentdb.Execute "INSERT INTO YourAuditTable(EmployeeID, AuditValue) VALUES(" & rst("Employee") & "," & rst("Audit 1") & ")"
  '/ and so on through all Audit columns
  rst.MoveNext
Loop

Obviously this process would depend largely on your table structure and such ....
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now