473,387 Members | 1,882 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to import Excel sheet to Access tables and respect the relationships

6
I have some excel sheets that I would like to manage in access. I've created the access tables and relationships; the excel sheet is only one table and with duplicate data, I'd like to make sure that when I import the sheet, the proper tables are filled correctly.

For example, the excel sheet is in the format

clientID Name phone City Country

In acces, I have a "Cities" table and a "Coutries" table, with the fields (e.g. for cities)
ID (primary key)
City (non duplicable)

The Clientes table is something like
ClientID Name phone cityId CountryId

and I would like the Clients, Cities and Coutries tables to be filled correctly, with the Clients' cityID and CountryID pointing to the right fields

I've followed this topic http://www.thescripts.com/forum/thread190306.html but I can't get it to work. In the end, when I try to execute the query, i get "You have chosen to add 0 rows etc etc" and It doesn't add anything to the db.


Thanks in advance
Dec 24 '07 #1
3 5557
nico5038
3,080 Expert 2GB
I have some excel sheets that I would like to manage in access. I've created the access tables and relationships; the excel sheet is only one table and with duplicate data, I'd like to make sure that when I import the sheet, the proper tables are filled correctly.

For example, the excel sheet is in the format

clientID Name phone City Country

In acces, I have a "Cities" table and a "Coutries" table, with the fields (e.g. for cities)
ID (primary key)
City (non duplicable)

The Clientes table is something like
ClientID Name phone cityId CountryId

and I would like the Clients, Cities and Coutries tables to be filled correctly, with the Clients' cityID and CountryID pointing to the right fields

I've followed this topic http://www.thescripts.com/forum/thread190306.html but I can't get it to work. In the end, when I try to execute the query, i get "You have chosen to add 0 rows etc etc" and It doesn't add anything to the db.


Thanks in advance
When importing Excel data into Access, the easy way is to link a table to the excel sheet.
Next use Maketable or Append queries to fill your tables.
Using an ID for City and Country will make your imports harder, I would just use a table with "City" and "Country".
But when you want such an ID then first use an append query to add the distinct cities like:
Expand|Select|Wrap|Line Numbers
  1. select into tblCity (City) select distinct city from tblExcel
  2.  
Next create a query that joins the tblExcel by the City and use the CityID field instead of the city. Now you can use that query to append the tblClients.
(Ofcourse the same mechanism can be used for the Countries).

Getting the idea ?

Nic;o)
Dec 31 '07 #2
inepu
6
hi Nic, thanks for the reply

I'm a bit rusty on my relational DBs, so I'm a little confused about not using the cities/coutries table with and ID field.

If my Clients table has several clients from the same city or country, won't that mean that my DB will have several duplicate strings? I was using the ID field as a pointer (thinking that it's better to have a duplicate integer than a duplicate string, and easier for the database to index and search=

Thanks in advance
Jan 1 '08 #3
nico5038
3,080 Expert 2GB
About "If my Clients table has several clients from the same city or country, won't that mean that my DB will have several duplicate strings?", you're correct.
We use a tblCity to have control over the cities that can be entered and to follow the normalization rules. These don't describe however that you need to use an ID field instead of the city as a ForeignKey (FK). I often use just the City as the sole field in a separate city table.
Thus the size of the foreignkey is indeed a bit larger but I save the additional space needed in the tblCity and the hassle of maintaining the ID.
The advantage of an additional tblCity is the fact that when referential integrety is active you can change the name of a citi in tblCity and that the FK will show the corrected name in all related tables.
Under the hood Access will use an internal index to make sure that the correct cityname is displayed for a FK. So basically Access builds such an index (ID) field already.

Getting the idea ?

Nic;o)
Jan 1 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Fred | last post by:
Hi. How do I import while mapping an excel table to an access table please??? I've searched around and all I can find is a software product or code that does the same thing as the access...
4
by: Steve Jorgensen | last post by:
I'm restarting this thread with a different focus. The project I'm working on now id coming along and will be made to work, and it's too late to start over with a new strategy. Still, I'm not...
7
by: Ruben Baumann | last post by:
Just wondered if anyone has had occasion to use, or does use, FileMaker, or Raining Data's Omnis, or Alpha5's software, and how they compare with Access? Ruben
8
by: Nick M | last post by:
Hello All, Excellent info here Thanks! I am very new to using access in general and I am on a learning curve. I'm trying to import an excel workbook (with worksheets) into an access db via a...
0
by: acharyaks | last post by:
Hi life saver, I am using excel component for the development. The purpose is to connect to excel through the odbc connection string. Then through the connection extract data into a dataset and...
10
by: Niklas | last post by:
Hi Before I start coding I need to be sure that nobody else has not done it yet and that I can use it. I need an import utility which import data from Excel to a database or some object in...
2
by: madeleine | last post by:
I'm hoping the answer to this is that I'm just doing something silly, but I'm really scratching my head over this one. I'm importing data from multiple workbooks, each workbook has a sheet called...
7
by: TG | last post by:
hi! I am trying to create a sql server table from an excel sheet. Here is the code I have: 'This procedure the xlsx file and dumps it to a table in SQL Server
2
hemantbasva
by: hemantbasva | last post by:
Note We need to have a template on server for generating report in multiple sheet as we do not had msoffice on server moreover this require a batch job to delete excel file created by the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.