Solved

Importing data to MS Access from MS Excel

Posted on 2014-04-20
3
53 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
  • 2
3 Comments
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
Comment Utility
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
Comment Utility
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 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

744 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

13 Experts available now in Live!

Get 1:1 Help Now