473,405 Members | 2,287 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,405 software developers and data experts.

2 table link in access, 3rd table needed?

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 1711
Scott Price
1,384 Expert 1GB
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>tblClientEvents, and tblEvents>tblClientEvents. 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
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>tblClientEvents, and tblEvents>tblClientEvents. 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 Expert 1GB
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
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.EventName would work. Is this a simple form error?

Thanks for your help
Sep 13 '07 #5
Scott Price
1,384 Expert 1GB
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
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 Expert 1GB
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
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 ?...
6
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...
6
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...
3
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...
0
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...
12
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....
7
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...
7
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...
10
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...
7
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...
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
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...
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...
0
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...

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.