473,563 Members | 2,916 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

6 New Member
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.ht ml 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 5574
nico5038
3,080 Recognized Expert Specialist
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.ht ml 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 New Member
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 Recognized Expert Specialist
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
15494
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 wizard..... If I have to write vb code, where is a sample??? Or do I import the excel in to a new spreadsheet and then write some kind of querey to...
4
3014
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 coming to a firm conclusion over whether it was the better approach, and wonder if I should do it differently the next time I'm faced with a similar...
7
2153
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
6544
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 macro. (I'll get to using VB later on). What I would like to do is import a single workbook w/three seperate worksheets into three seperate access...
0
2812
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 then save the data into a client machine (Intranet) as excel page using the excel component (using Excel = Microsoft.Office.Interop.Excel;) in the...
10
11804
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 .NET. The data in Excel is not in structured columns but can exist everywhere in the workbook. For example if I am supposed to import a person and all...
2
3488
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 SubSAT and I need to get specific data from that into the database. I'm finding that if I have the workbook open on my desktop then the SubSAT %...
7
12054
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
6395
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 method.... it creates 6 sheets # region Namespaces using System;
0
7664
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7885
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7638
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7948
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3642
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1198
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.