Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 72
  • Last Modified:

Importing data to MS Access from MS Excel

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
egalois
Asked:
egalois
  • 2
1 Solution
 
Dale FyeCommented:
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
 
egaloisAuthor Commented:
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
 
Dale FyeCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now