473,485 Members | 1,399 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to Combine Data from multiple tables or sources?

I am at a complete loss on how to do this. I am using Microsoft Access
2000, to implement a preliminary version of a reasonably modest
relational database.

I have two Access Tables (imported from MS Excel spreadsheets), and I
need to somehow get the data for a "Person_ID" brought over from one to
the other.

In Table_A, there are many records for each person, and the first and
last name are included, but the Person_ID field is empty. There are
more than 65,000 records.

In Table_B, there is only one entry for each person, and each record
contains a field called Person_ID. There are more than 15,000 records.

I cannot figure out any way to bring the Person_ID data from Table_B to
Table_A, to allow me to create a relationship through the Person_ID
field to several other tables.

Can someone point me to a resource that would tell me how to do this?
If the data sources were smaller, I could export them to Excel and
manipulate them there, and then re-import tham, but there are more than
65,000 records.

Jul 19 '06 #1
8 22185
user an update query to set the value of the TableA.personID to the
value of TableB.personID where

UPDATE TableA
SET PersonID = TableB.PersonID
WHERE TableA.FirstName=tableB.FirstName
AND TableA.Lastname=tableB.Lastname
AND TableA.SSN=TableB.SSN ...

but you need a combination of fields in the two tables to define an
accurate relationship.
How do you know which records are related just by looking at them? You
need to join on that/those field(s) in your update query.

Jul 19 '06 #2
This sounds like the right sequence of directions, but I don't know how
or where to input this kind of script into Access 2000.
UPDATE TableA
SET PersonID = TableB.PersonID
WHERE TableA.FirstName=tableB.FirstName
AND TableA.LastName=tableB.LastName
Jul 19 '06 #3
Can anyone point me to a resource that explains "Update Queries" in a
useful way? Or perhaps suggest what I may be doing wrong here?

I have now tried this a number of different ways, but no matter what I
do, Access simply prompts me for the value of each field, rather than
drawing any data from the database tables.

There are two tables: "Quotes_Table" and "Persons_Table", each
containing fields called
First_Name, Last_Name, and Person_ID. In the "Quotes_Table" there are
multiple entries for each person, including first and last name but NOT
Person_ID. I want to "bring over" the Person_ID field from the
Persons_Table. I have tried doing this with the Person_ID fields in
the two databases set to be related, and again in several permutations
without any relationship set; it seems to make no difference. (I cannot
relate the other fields (First_Name or Last_Name), apparently because
they are not primary keys?)

No matter what I do, the system prompts me to enter values. At one
point, I thought this was an issue related to Access inserting brackets
around some fields but not others, but the query functions exactly the
same with or without brackets:

UPDATE Quotes_Table SET Quotes_Table.Person_ID =
[Persons_Table].[Person_ID]
WHERE (([Quotes_Table].[Person_ID]=[Persons_Table].[First_Name]) And
([Quotes_Table].[Person_ID]=[Persons_Table].[LastName]));

UPDATE Quotes_Table SET Quotes_Table.Person_ID =
Persons_Table.Person_ID
WHERE ((Quotes_Table.Person_ID=Persons_Table.First_Name) And
(Quotes_Table.Person_ID=Persons_Table.LastName));

Can anyone point me to a resource that explains "Update Queries" in a
useful way? Or perhaps suggest what I may be doing wrong here?

Jul 19 '06 #4
you might want to start with a select query where you join the tables
together to get the data together. then turn that into an update query.

Jul 19 '06 #5
I don't understand how I'd do that, but I think the logical sequence of
what I want is:

For each record in [Quotes_Table]:
Find the entry in [Persons_Table] with the same First_Name and
Last_Name;
SET [Quotes_Table].[Person_ID] = [Persons_Table].[Person_ID]

or

For each record in [Persons_Table]
Find all entries in [Persons_Table] with the same First_Name and
Last_Name;
For all matching records, SET [Quotes_Table].[Person_ID] =
[Persons_Table].[Person_ID]

Jul 19 '06 #6
Try this... the problem is that with 65K+ records, I don't know if
you're going to get a proper relationship working.

UPDATE Quotes_Table INNER JOIN Persons_Table ON
(Quotes_Table.PersonLast = Persons_Table.LastName) AND
(Quotes_Table.PersonFirst = Persons_Table.FirstName) SET
Quotes_Table.CustomerID = [Persons_Table].[PersonID];
Copy and paste the above statement into a query.

Create a new query. Click on the SQL button in DESIGN view. paste.

Oh, make a backup of your table before you do it... don't want to mess
up the data you have with no back door.

Jul 19 '06 #7
Thanks for the detailed response, but Access just prompts me manually
for each field again. I am exporting the data to Excel, where I will
break it into chunks to merge manually -- it will probably take 3-4
hours but I don't think I will find a faster way.

Jul 19 '06 #8

Mark Welch wrote:
Thanks for the detailed response, but Access just prompts me manually
for each field again. I am exporting the data to Excel, where I will
break it into chunks to merge manually -- it will probably take 3-4
hours but I don't think I will find a faster way.
Once way to get the prompts is to not have those fields in your table.
What happens if you try to create a relationship between the two tables
(on FirstName and LastName)? If that part works, you _may_ be able to
run an update. The problem is that you have to have a one-to-many
relationship between the two tables.

If you have to do it in Excel, you can use H/VLookup, but it's about
the same thing. I'd spend a few more minutes in Access.

Try running the Find Unmatched query wizard and see if there are values
in one table that are not in the other. That will tell you which
records are screwing things up for you. Lots easier than doing
everything manually.

Jul 19 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
38620
by: Sami | last post by:
I can create queries and reports based on info from one table. How do I create one using information from multiple tables. What do I need to make sure the information from one table will be...
1
23322
by: mojo | last post by:
We have set up an Access database with tables x,y, & z where we would like to have multiple people entering data into a table x. Each person has an identical copy of the database on their PC's. ...
7
2232
by: jude | last post by:
Hello, We are starting to discuss a new ASP.NET application that will be a data acquisition display application. The data to be displayed will come from multiple sources--database tables, serial...
1
1954
by: abc my vclass | last post by:
How to design and build reports which data source from business logic layer ? Is there any documents or tutorials explain the steps to design and build reports if my projects' data source from...
6
3119
by: Mike Wilson | last post by:
Dear Group, I have a heirarchical set of database tables, say - "order" and "order_type" and want to display a series of orders in a grid control, and in place of the order_type foreign key...
5
2984
by: jhutchings | last post by:
Hello everyone, I have a database where I collect shipment data from various tables. However, I have a problem. Whenever I want to see shipping data for orders that were set to ship on or before...
0
1585
by: Christoph Haas | last post by:
Hi, list... I have written an application in Perl some time ago (I was young and needed the money) that parses multiple large text files containing nested data structures and allows the user to...
13
7979
by: deville75 | last post by:
Hi, I'm somewhat new to MS Access and I'm having trouble with displaying two forms. Firstly my program is going to use a search button to search through several different Tables. The Search Form...
1
3402
by: bluereign | last post by:
Thank you for your assistance. I am a novice looking to JOIN and append or combine records from 2 current Tables into 2 new Tables named below. I have been able to JOIN Tables with the script...
0
7090
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
6960
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...
1
6825
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...
0
5418
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4857
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...
0
4551
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3063
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1376
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 ...
0
247
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.