I have a table for customers, one for their site addresses and one for their contact details at the relevant site. So these three tables are joined by one-to-many relationships (their may be more than one contact at a particular site address) using AutoNumber fields.
I have to import the relevant details from a flat-file Excel spreadsheet, and Append them to the existing tables.
I managed to add the customer details to the main table, but am struggling thereafter with ‘key violations’ and ‘cross-products’!!
Is it possible to update these tables in one query? How can I resolve the key violations? Thank you, Andy.
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Updating more than one table (97)
Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Updating more than one table (97)
- This topic has 10 replies, 4 voices, and was last updated 23 years, 9 months ago.
AuthorTopicWSandrewgibsonsw
AskWoody LoungerAugust 20, 2001 at 11:29 am #359283Viewing 0 reply threadsAuthorReplies-
WSTim K.
AskWoody Lounger -
WSandrewgibsonsw
AskWoody LoungerAugust 20, 2001 at 2:15 pm #538128Thanks. I can append the customer list to the customers table – it gives me key violations if the company already exists in the list, which I can ignore. I have then been able to append the addresses to the addresses table, and it pulls across the company id for the relevant company. However, it is at the third stage, when I want to append contact names to the contacts table that I get problems. I get a cross-product of the records – that is, if there are four addresses and six contacts it suggests that it will append 24 records!
How can I get rid of the cross-product and ensure that it will populate the contacts table with the correct AddressID numbers? Help!
-
WScharlotte
AskWoody LoungerAugust 20, 2001 at 11:47 pm #538242What table are you appending the records to? Your addresses don’t belong in the contact table, especially if a contact may be associated with multiple addresses. The addresses belong in an address table. Then you can link a contact to a particular address using a join table, which will hold a key to the contact table and a key to the address table.
-
WSandrewgibsonsw
AskWoody LoungerAugust 21, 2001 at 7:42 am #538296The Excel data is in a flat-file format. It includes the company name, an address and a contact on one row. The company name is then repeated for different addresses and different contacts.
I want to add all this data to the three relevant tables. If the company doesn’t exist then a new record is created for it.
Any one company may have several site addresses, and for any one site address there may be more than one contact.
Hope the above helps?!
-
WSRupert
AskWoody Lounger -
WSandrewgibsonsw
AskWoody LoungerAugust 21, 2001 at 1:03 pm #538333Thanks. I’ve got it to work, in a roudabout way – although I still don’t fully understand what the problem is.
In Excel I have a list of companies together with several addresses and in turn several contacts. I was hoping that Access would be able to ‘recognise which company we are referring to, add the addresses to the addresses table (together with the correct companyID), and similarly add the contacts (and correct addressID) to the contacts table’ – in one or two steps!
It seems so simple when explained in English. Anyone willing to have a stab at trying to explain the problem?! Cheers, Andy.
-
WScharlotte
AskWoody LoungerAugust 21, 2001 at 2:06 pm #538349You have a one to many join between Company and Contact and a one to many join between Company and Address. Can a contact be associated with only a single address? If so, you could add an address key to the Contact table. Alternatively, you can have a join table ContactAddress that holds a contactID and an AddressID for each contact-address combination. Can a company have a contact that is not associated with an address?
The way I do this is to import the spreadsheet into a flat Access table with an autonumber key in it so that I have a way to uniquely identify each row. Then I add fields for all the keys I’m going to be creating–in this case a CompanyID, a ContactID, an AddressID. I’d then start by populating the Company table with unique company names. Then I would update the flat table with companyIDs by linking the company name field in the flat table to the company name field in the Company table and updating the flat table’s companyID field. Next, I’d identify all those company names that were near duplicates and clean them up–Microsoft and Microsoft Corp, for example. Make them uniform and rerun the update so that all of the Microsoft entries would have one and only one CompanyID. Then leave the others in the Company table but have a field in there for Usable and set it to false for the “bad” company names. That will keep them from getting in again if someone has fat fingers.
Now you have flat records with a CompanyID in them, so you can now create Address and contact records. You already have the CompanyID, so all you need to do is append the relevant information, including the companyID to the other tables. You do *not* append the company name to the other tables, only the companyID, since that’s the relational link between the tables. Create the Address record first and then update the flat table with the AddressID just as you did the companyID. I personally wouldn’t bother to clean up the address records because believe me, they won’t stay cleaned up. Once you have Company and Address records created and their keys inserted, you can create the contact records and insert the Address key if you wish. If you decide to use a join table for Contact-Address (my preference), you can easily populate that table with the contact-address ID pairs from the flat table.
Hope this helps.
-
WSandrewgibsonsw
AskWoody LoungerAugust 21, 2001 at 2:49 pm #538366Thanks very much Charlotte. A join table has not been used, and you have described what I have been doing to get this to work.
Any one company will have several addresses. At any one address there will possibly be several contacts. The contacts could also be the same for several different addresses. ALSO, it is possible that several companies may give the same address, just to complicate things!
Could this set up work with a join table and why would it be preferable? Andy. -
WScharlotte
AskWoody LoungerAugust 21, 2001 at 10:13 pm #538438I wouldn’t try to hard to filter the addresses down because they tend not to be entered consistently. I worked for a direct marketing company for 3+ years and finally came to the conclusion that unique addresses were nearly impossible to manage so I stopped trying so hard. You might find it simpler to have a company field in the address table and just accept whatever address is entered for a company, creating a unique address ID for each record. You could use the companyID to filter out the appropriate addresses for a company and its contacts that way. It really depends on how much control you will have over the address records. I found that users were more likely to enter addresses than they were to look them up to see if one already existed that was *almost* exactly the same.
If the addresses can be linked to multiple contacts and the contacts can be associated with multiple addresses, you *have* to use a join table because it’s the only way to create a many-to-many join. With a join table, you can connect each contact to whatever addresses are appropriate. If a single address has multiple contacts, you’ll have as many records as you need. If a single contact is associated with multiple addresses, no problem. There simply isn’t any other way to do it in Access.
-
WSandrewgibsonsw
AskWoody LoungerAugust 22, 2001 at 11:23 am #538514Although some companies may share the same address, this is more of a coincidence than anything central to the design of the database. Any one contact is, in general, based at a particular address for a particular company. Although in theory the same contact may occur for different addresses and/or companies the likelihood of this is extremely rare.
Therefore, I am still unconvinced of the need for a join table. What problems are likely to occur if I don’t use a join table? Andy.
-
-
-
-
Viewing 0 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
0Patch, where to begin
by
cassel23
2 hours, 14 minutes ago -
CFPB Quietly Kills Rule to Shield Americans From Data Brokers
by
Alex5723
5 hours, 14 minutes ago -
89 million Steam account details just got leaked,
by
Alex5723
13 hours, 38 minutes ago -
KB5058405: Linux – Windows dual boot SBAT bug, resolved with May 2025 update
by
Alex5723
13 hours, 47 minutes ago -
A Validation (were one needed) of Prudent Patching
by
Nibbled To Death By Ducks
4 hours, 45 minutes ago -
Master Patch Listing for May 13, 2025
by
Susan Bradley
7 hours, 9 minutes ago -
Installer program can’t read my registry
by
Peobody
6 hours, 44 minutes ago -
How to keep Outlook (new) in off position for Windows 11
by
EspressoWillie
2 hours, 32 minutes ago -
Intel : CVE-2024-45332, CVE-2024-43420, CVE-2025-20623
by
Alex5723
9 hours, 53 minutes ago -
False error message from eMClient
by
WSSebastian42
1 day ago -
Awoke to a rebooted Mac (crashed?)
by
rebop2020
1 day, 9 hours ago -
Office 2021 Perpetual for Mac
by
rebop2020
1 day, 11 hours ago -
AutoSave is for Microsoft, not for you
by
Will Fastie
7 hours, 48 minutes ago -
Difface : Reconstruction of 3D Human Facial Images from DNA Sequence
by
Alex5723
1 day, 14 hours ago -
Seven things we learned from WhatsApp vs. NSO Group spyware lawsuit
by
Alex5723
15 hours, 45 minutes ago -
Outdated Laptop
by
jdamkeene
1 day, 20 hours ago -
Updating Keepass2Android
by
CBFPD-Chief115
2 days, 1 hour ago -
Another big Microsoft layoff
by
Charlie
2 days, 1 hour ago -
PowerShell to detect NPU – Testers Needed
by
RetiredGeek
1 hour, 59 minutes ago -
May 2025 updates are out
by
Susan Bradley
29 minutes ago -
Windows 11 Insider Preview build 26200.5600 released to DEV
by
joep517
2 days, 7 hours ago -
Windows 11 Insider Preview build 26120.3964 (24H2) released to BETA
by
joep517
2 days, 7 hours ago -
Drivers suggested via Windows Update
by
Tex265
2 days, 7 hours ago -
Thunderbird release notes for 128 esr have disappeared
by
EricB
3 hours, 13 minutes ago -
CISA mutes own website, shifts routine cyber alerts to X, RSS, email
by
Nibbled To Death By Ducks
2 days, 14 hours ago -
Apple releases 18.5
by
Susan Bradley
2 days, 8 hours ago -
Fedora Linux 40 will go end of life for updates and support on 2025-05-13.
by
Alex5723
2 days, 15 hours ago -
How a new type of AI is helping police skirt facial recognition bans
by
Alex5723
2 days, 16 hours ago -
Windows 7 ISO /Windows 10 ISO
by
ECWS
1 day ago -
No HP software folders
by
fpefpe
2 days, 23 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.