Solved

Importing data to MS Access from MS Excel

Posted on 2014-04-20
3
60 Views
Last Modified: 2015-07-26
I have 1000 rows or "records" of applications in my excel spreadsheet.  But they only represent 100 unique devices that are already represented in my MS Access database.   I have successfully linked my excel spreadsheet, I have even been able to move it to a table, but this is not enough.  

I want to get the data into it's respective tables and associated with the respective machines.   I'm stuck at this point.   MS Office 2010.
0
Comment
Question by:egalois
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 48

Expert Comment

by:Dale Fye (Access MVP)
ID: 40011855
need more info.  Would need to know the structure of your source table (the linked Excel file) and of the data table(s) you are trying to import it into.  Also would need to know what the Primary Key (unique field in your main table) field is and what the Foreign Key field (the field in your Excel table that identies how each of the 1000 records relate to the 100 unique devides.
0
 

Author Comment

by:egalois
ID: 40011872
The excel sheet is 5 columns titled with CamelCase.  The columns are each formatted as text;  HostName, Application, AppVersion, ProductKey, Maker,      

The primary key in the Main table is autogenerated by MS Access.  Default type auto key.  

The key in my excel sheet is also generated by Access on import - I can easily just delete the link and table I've created and import it again with a different key though.  Just "autogenerate" is what I happened to choose in my experiment.  

The data tables that are in the database begin with Assets, and then are distributed based on "Subject" or "Description of Subject" - a moderately designed, normalized database.   So for example, in the Assets table there is a one to many link from "AssetsID" to a "join" table that includes "ApplicationID"...    

The idea being, I can look up an asset and see what applications are installed.   I can elaborate on any point here but not sure specifically where to elaborate.   Or how best to show what I have....    

Application table:

tblApplication

ApplicationInternalIdentifier
Application
Maker
AppVersion

tblAsset

HostName
AssetTypeID
AssetModel
AssetInernalIdentifier

Maybe I can clarify my question further by saying there are many examples and tutorials on how to import data into a single table.  But I'm needing to bring my data into my database and distribute it appropriately to the respective fields in across many tables.  

I imagine I might create a query that includes all the fields, in all the tables that I'm bringing the data in for, and then some how reverse the process so that when the query is run, it moves the data to the respective fields from my inport into the tables....  I'm missing a fundamental understanding.
0
 
LVL 48

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 40012264
So, what we know you have now is at least two tables, Assets (which represent the host computer name) and Applications (which represents the applications installed across all of the machines).  You will need a third table, AssetApps, which keeps track of the applications installed on each host, and possibly the product key for that app, with fields of HostID, AppID.

Assuming that your Assets table has a record for each host, you would need to start out by confirming that each Application is represented in tblApplication.  I would write an append query similar to:

INSERT INTO tblApplication (Application, Maker, AppVersion)
SELECT EF.Application, EF.Maker, EF.AppVersion
FROM ExcelFile EF
LEFT JOIN tblApplications A
ON EF.Application = A.Application
AND EF.Maker = A.Maker
AND EF.AppVersion = A.AppVersion
WHERE A.ApplicationInternalIdentifier IS NULL

This will ensure that each application, version is adequately represented in tblApplications.

Then, you will need to create another query that joins the Excel File to both the Assets table (on HostName) and tblApplications (on the Maker, Application, and AppVersion columns).  Save this query (qry_EF_with_PKs) and use it in another query to update your AssetApps table.  You will probably need to do that in three steps.

1. Update records already in the AssetApps table with the current version and product key if the combination of AssetInernalIdentifier and ApplicationInternalIdentifier already exist

2.  Append new records that are not already a part of the AssetApps table

3.  Delete records that are in the AssetApps table that are not in the Excel table.  Instead of doing a bulk delete I would display this list in a form or report so that you can validate that those application/version combinations are no longer installed and then delete them via a form with a Delete button.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

729 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