473,769 Members | 5,205 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

2 table link in access, 3rd table needed?

4 New Member
Hi, been trying to do this for literally hours, cannot for the life of me remember how to do it.

I have one table for Clients, just surname, forename, address, contact number etc, and I have added an ID field.

I have another called Events, where basic information on events i hold is kept, name/date etc, and i also have an Event ID field in this table.

I have setup forms to add new client to the database, and add a new event to the database.

One client can go to multiple events and obviously one event has multiple clients. I need a way of bringing up an event and then being able to select which clients were at the event or bringing up a client and linking an event or several events to their record.


I thought the way to do this was to have a third table containing ID and Event ID but i have played around with this with no success.

Its MS access 2000 on win XP.

Many Thanks
Sep 13 '07 #1
7 1731
Scott Price
1,384 Recognized Expert Top Contributor
Hi, been trying to do this for literally hours, cannot for the life of me remember how to do it.

I have one table for Clients, just surname, forename, address, contact number etc, and I have added an ID field.

I have another called Events, where basic information on events i hold is kept, name/date etc, and i also have an Event ID field in this table.

I have setup forms to add new client to the database, and add a new event to the database.

One client can go to multiple events and obviously one event has multiple clients. I need a way of bringing up an event and then being able to select which clients were at the event or bringing up a client and linking an event or several events to their record.


I thought the way to do this was to have a third table containing ID and Event ID but i have played around with this with no success.

Its MS access 2000 on win XP.

Many Thanks
You are correct, you need a third linking table called tblClientEvents or whatever you want to name it. It basically will have three fields; ClientEventID Autonumber PK, ClientID Number FK, EventID Number FK.

Create your relationships between tblClients>tblC lientEvents, and tblEvents>tblCl ientEvents. Then you write a query that pulls from this linking table based on ClientID or EventID or both...

Any questions feel free to ask!

Regards,
Scott
Sep 13 '07 #2
jp45678
4 New Member
You are correct, you need a third linking table called tblClientEvents or whatever you want to name it. It basically will have three fields; ClientEventID Autonumber PK, ClientID Number FK, EventID Number FK.

Create your relationships between tblClients>tblC lientEvents, and tblEvents>tblCl ientEvents. Then you write a query that pulls from this linking table based on ClientID or EventID or both...

Any questions feel free to ask!

Regards,
Scott

Sorry, this might be the bit i am getting confused with, the FK's in the 3rd table, do i use the lookup wizard to link these as FK's or does the relationship window sort that out for me when i create the link?

I think the best i got so far was for the form to show me peoples name, and then there was a combo box with an event, but i could only link one event to each person. Not sure if that helps at all?

Regards
Sep 13 '07 #3
Scott Price
1,384 Recognized Expert Top Contributor
Foreign Key is just the name we humans use to refer to the Primary Key of one table that is referenced in another table. This terminology has no significance to the database itself. When you create the relationship between the tables, you are creating what we call the FK.

These relationships should have referential integrity enforced. Both Cascade Update and Cascade Delete should be required.

Now create the query that pulls the information you want to display. For example:

Expand|Select|Wrap|Line Numbers
  1. SELECT tblClient.ClientName, tblClientEvents.ClientID, tblClientEvents.EventID, tblEvents.EventName FROM tblClientEvents INNER JOIN (tblClients INNER JOIN tblClientEvents ON tblClientEvents.EventID = tblEvents.EventID) ON tblClients.ClientID = tblClientEvents.ClientID WHERE tblClientEvents.EventID = 1
(This sql statement is off the top of my head... what you will likely be better off doing is using the design view grid to create your query, rather than just pasting this into the sql window of a new query)

Regards,
Scott
Sep 13 '07 #4
jp45678
4 New Member
I think I've got the query done properly, I'm having problems with actually linking a client to an event. I have created the query with the columns as described.
I thought it would just be a case of creating a form using this query.
So i created the form, and it is a main form with a subform - not sure if that is correct.
The client name shows up fine, in the main form, but then in the subform contained only a blank textbox and only allowed one input, ie not allowing a second one after inputting the first.

Ideally, a combo box with a list of tblEvents.Event Name would work. Is this a simple form error?

Thanks for your help
Sep 13 '07 #5
Scott Price
1,384 Recognized Expert Top Contributor
Is your subform in continuous form view? That would allow more than one entry.

Probably the simplest way is to place a combo box on the subform with row source set to
Expand|Select|Wrap|Line Numbers
  1. SELECT EventID, EventName FROM tblEvent ORDER BY EventName
and bound to the EventID field in your query. This will allow you to select whichever event you want from the events table.

Make the first column the bound column and set the column widths to 0", 1.5" and you will only be able to see the event name in the combo box.

Regards,
Scott
Sep 13 '07 #6
jp45678
4 New Member
I think i'm almost there. I now have a combo box containing the Events, but when i click on an Event in the list, it brings up

Object or class does not support the set of events

Thanks again
Sep 14 '07 #7
Scott Price
1,384 Recognized Expert Top Contributor
I think i'm almost there. I now have a combo box containing the Events, but when i click on an Event in the list, it brings up

Object or class does not support the set of events

Thanks again
What events do you have running for this combo box?

Do you have an AfterUpdate or BeforeUpdate expression/code/macro running? If so, what is it?

Regards,
Scott
Sep 14 '07 #8

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

Similar topics

2
1309
by: Ryan | last post by:
Little puzzle this. I need to link from SQL2000 to Access to get to a table held within an Access DB. Now you can link within Access to a SQL table, but can this be done the other way round ? It's the first time I've needed to do something like this. What I have is an application which was written (by me) with an Access backend (to run on a CD) and now it needs to run on SQL. However, I want to be able to swap over between backends so...
6
1695
by: M. Schroeder | last post by:
I use an Access-form to write into an external Oracle table via Oracle-ODBC driver. It is not a read-only connection, and batch autocommit mode set to "all successful statements". I can read all records from table, but update, insert, and delete is allowed on form level, but I cannot change records and I cannot insert. Whats wrong? Thanks, Schroeder
6
7585
by: Lewis Veale | last post by:
I have an Access 2000 front-end pointing at a SQL Server backend, with around 80 linked tables and views. I frequently need to point the front-end at different versions of the back-end, and achieve this by relinking the tables and views to use a different DSN. I use the Linked Table Manager > Select All > and tick the 'always prompt for a new location' box, then click OK. It correctly pops up the 'select data source' box, from which I...
3
3170
by: ChadDiesel | last post by:
Hello everyone. I need some advice on table structure for a new project I've been given. One of our customers sends us an Excel spreadsheet each week containing their order. Currently, someone formats the spreadsheet, prints it out, and manually picks out the products we need to ship. I want to import this into an Access table. Basically, the sheet with some data examples looks something like this: ...
0
1334
by: Redstone | last post by:
When attempting to refresh a link through ODBC to a table (T_Leases) in my SQL backend, I get an error message teling me the Jet Engine can't find an object (A differnet table T_LockTypes in the same SQL). I checked and am able to open, design and query the second table in SQL. There are no relationships between these two tables. I am unable to query the table. I tried to refresh the second table and am told the object does not exist....
12
3113
by: kabradley | last post by:
Hello, Thanks for looking at my post and hopefully having an answer or at least a suggestion to my problem. I currently work at a financial planning office that deals with many clients and accounts. Each client may have multiple accounts such as an individual, IRA, and possibly a joint tenant account. Each one of these accounts for the particular client is contained in a 'Portfolio'. For example, Joe Smith may have 3 accounts: Joe Smith...
7
4827
by: Kamal | last post by:
Hello all, I have a very simple html table with collapsible rows and sorting capabilities. The collapsible row is hidden with css rule (display:none). When one clicks in the left of the expandable row, the hidden row is made visible with css. The problem is when i sort the rows, the hidden rows get sorted as well which i don't want and want to be moved (while sorting) relative to their parent rows. The following is my complete html code...
7
4774
JodiPhillips
by: JodiPhillips | last post by:
Hi, My first post! I've basically taught myself Access and the little I know about VBA through reading these forums and a couple of books. I'm in the middle of a project at work - to put it mildly I've been thrown in at the deep end, in the past I've just done simple databases and that's been fine. Now, however I have to "roll out" various front ends to a single back end for initially 10 users (and the bosses have plans for this to go to...
10
49616
by: Dean | last post by:
My client has a db I am working that uses temp tables. During an update procedure, I had the code If fTableExists(tempTblName) = True Then DoCmd.DeleteObject acTable, tempTblName Then I thought of using: If fTableExists(tempTblName) = True Then CurrentDb.Execute "DROP TABLE " & tempTblName Is there an advantage to either? What really be cool is DROP TABLE deleted the table and I didn't have to compact the db so much.
7
8429
by: franc sutherland | last post by:
Hi everyone, I am using Access 2003. I have a database with a table in it which is linked to an excel spreadsheet. When I install the database on someone else's system, the pathname to the excel file is different. Howwever, as it is in runtime on their system, I can't update the link using the Linked Table Manager. Is there a way of using a public constant to store a path which can be altered in advance and then combined with a...
0
9589
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10222
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9999
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8876
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5310
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3967
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
2
3570
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.