Solved

Importing data to MS Access from MS Excel

Posted on 2014-04-20
3
55 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)
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 47

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Tags from access to excel 3 30
Error in query expression 3 37
Running sum query 6 32
Storing Combo Box Selection in Table 12 45
This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

920 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

15 Experts available now in Live!

Get 1:1 Help Now