473,803 Members | 2,937 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Create a query to list which tables an item is located in

We have a Microsoft Access 2000 database consisting of 20 tables
covering 20 different events. In each table, there are 3 Team
members, a date of the event and several unique fields for the event,
which vary from table to table. There is also another table that
holds the team members' details. There is a one-to-many relation
between the Team member table and the other table's 3 Team member
fields, so that the event tables only holds three team ID's rather
than the Team member details directly.

All went well until my manager asked me that he needs a query that
will give a list of members along with which events they were involved
in including the dates the event took place. Sounds simple? Yet I
cannot figure out how to build the query :-(

Ideally, the query will give three columns: 1st column showning the
Team member ID, 2nd column showing the table name (i.e. the name of
the event) and the third column showing the date of the event.

Is this possible in Microsoft Access?

The only solution I can think of is to create another table that would
hold the team member ID, Event name and date such that each time an
addition would be made to any table, a Macro would add the team member
ID's along with the table name and dates to this extra table.
However, I would also have to add more Macros to cover should someone
change an existing record (such as change one of the team member IDs)
or even delete a record.
Nov 13 '05 #1
5 1838
Hi Sean,

It looks like the problem is with the design of your database.

It might have been better to have just three tables:

1. Events
2. Team Members
3. Data

The Events Table should have an EventID field (primary key). The
table should hold 20 records, one for each event, holding its date,
time, venue, etc.

The Team Members Table should have a TeamMemberID field (primary key).
The table should hold one record for each Team Member, name,
department, etc.

The data table will have just two fields: (1) fkEventID and (2)
fkTeamMemberID. (These are known as foreign keys.) You only store
two numbers in each record of this table, which link back to the other
two tables.

You need a one-to-many relationship from the EventID field (in the
Events Table) to the fkEventID field (in the Data Table).

Also, you need a one-to-many relationship from the TeamMemberID field
(in the Team Members Table) to the fkTeamMemberID field (in the Data
Table).

You need one record in the Data Table for each combination of Event
and Team Member (ie three records for each event, but you can have as
many as you like), eg:

Record 1 - fkEventID=1 - fkTeamMemberID= 5
Record 2 - fkEventID=1 - fkTeamMemberID= 11
Record 3 - fkEventID=1 - fkTeamMemberID= 16
Record 4 - fkEventID=2 - fkTeamMemberID= 7
Record 5 - fkEventID=2 - fkTeamMemberID =4
Record 6 - fkEventID=2 - fkTeamMemberID= 17
Record 7 - fkEventID=2 - fkTeamMemberID= 9
etc

So for 20 events and three Team Members per event, the Data Table will
hold 60 records.

With your data structured in this (normalised) way, you should be able
to run any reports/groupings you like.

For your report, create a query showing all three tables in the QBE
grid and drag in all fields to the grid. You can drag down the
asterisk from each table.

For your report, base your report on the query. Use the Grouping and
Sorting toolbar button to group and sort as your boss wants.

HTH
Geoff

Nov 13 '05 #2
Sean, I think you would be best to redesign your db to a relational database configuration to
something like this:

tblMembers:
MemberID(Primar yKey)
fName
lName
activeMember(Ye sNo field)
.....

tblEvents:
EventID(Primary Key)
EventName
EventDate
activeEvent(Yes No field)
.....

tblMemberEvents : (these 2 fields form the PrimaryKey)
MemberID(Foreig nKey)
EventID(Foreign Key)

Now you can assign a member to any event and any event to any member. It's now easy to pull a
member and display all the events they are associated with and the dates of those events. Now if
you change the description of a member or event you only need to do it in one place and it will be
reflected in all your records. This will also prevent the user from deleting a member or event if
has a record in the tblMemberEvents table. If you don't want to use the member or event anymore set
the active field to false and filter those records out.

Hope this helps!

--
Reggie

----------
"Sean Byrne" <se************ *****@yahoo.com > wrote in message
news:8b******** *************** ***@posting.goo gle.com...
We have a Microsoft Access 2000 database consisting of 20 tables
covering 20 different events. In each table, there are 3 Team
members, a date of the event and several unique fields for the event,
which vary from table to table. There is also another table that
holds the team members' details. There is a one-to-many relation
between the Team member table and the other table's 3 Team member
fields, so that the event tables only holds three team ID's rather
than the Team member details directly.

All went well until my manager asked me that he needs a query that
will give a list of members along with which events they were involved
in including the dates the event took place. Sounds simple? Yet I
cannot figure out how to build the query :-(

Ideally, the query will give three columns: 1st column showning the
Team member ID, 2nd column showing the table name (i.e. the name of
the event) and the third column showing the date of the event.

Is this possible in Microsoft Access?

The only solution I can think of is to create another table that would
hold the team member ID, Event name and date such that each time an
addition would be made to any table, a Macro would add the team member
ID's along with the table name and dates to this extra table.
However, I would also have to add more Macros to cover should someone
change an existing record (such as change one of the team member IDs)
or even delete a record.

Nov 13 '05 #3
Thank you very much for your help ;-)

As I originally thought the database layout was designed as the way it
should be implemented in Access, I done the mistake of building all
the tables and forms only to realise the above problem when I started
working on the Query.

In the end, I got out a blank of paper and redesigned the database
trying to keep the event tables, but moving Team Members to a Team
Member table, Event details (comments, location, date) to an Event
table. I added an Event ID to the Event Table as a primary key and
then used it has a primary key to the 20 other tables and Team member
table. I created a one-to-one relationship between the 20 event info
tables and the event table.

Once built, it made querying based on Team Members and Event locations
very simple. The Forms and Reports were very simple to build as a
result by using Subforms and also means that each record is not
restricted to 3 Team Members should this requirement change later on.

Sorry that I could say what is on these 20 tables or what this
database is used for as the information stored in database is
confidential and we must have it ready to supply to the customer later
this week. Every table has its own set of unique fields (apart from
Team Members, location and certain event details) which meant I had to
stick with 20 tables, but moving out the duplicates present on each
table made such a difference and I was able to build all the necessary
queries and reports.

Best Regards,
Seán.
Nov 13 '05 #4
Glad to hear!

--
Reggie

----------
"Sean Byrne" <se************ *****@yahoo.com > wrote in message
news:8b******** *************** ***@posting.goo gle.com...
Thank you very much for your help ;-)

As I originally thought the database layout was designed as the way it
should be implemented in Access, I done the mistake of building all
the tables and forms only to realise the above problem when I started
working on the Query.

In the end, I got out a blank of paper and redesigned the database
trying to keep the event tables, but moving Team Members to a Team
Member table, Event details (comments, location, date) to an Event
table. I added an Event ID to the Event Table as a primary key and
then used it has a primary key to the 20 other tables and Team member
table. I created a one-to-one relationship between the 20 event info
tables and the event table.

Once built, it made querying based on Team Members and Event locations
very simple. The Forms and Reports were very simple to build as a
result by using Subforms and also means that each record is not
restricted to 3 Team Members should this requirement change later on.

Sorry that I could say what is on these 20 tables or what this
database is used for as the information stored in database is
confidential and we must have it ready to supply to the customer later
this week. Every table has its own set of unique fields (apart from
Team Members, location and certain event details) which meant I had to
stick with 20 tables, but moving out the duplicates present on each
table made such a difference and I was able to build all the necessary
queries and reports.

Best Regards,
Seán.

Nov 13 '05 #5
Good luck with your project.
Regards
Geoff
Nov 13 '05 #6

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

Similar topics

0
1613
by: Dave | last post by:
Hi all, I have a problem with a query. (well, I actually have a few problems...) Here is my query. select FOCUS.SiteName, FOCUS.URL, OTWAdCars.* , REGION.SiteName as RegionSite, REGION.URL as RegionUrl from OTWSite as FOCUS right join OTWSite as REGION
6
8521
by: Rudolf Bargholz | last post by:
Hi , I have the following tables ------------- PAX: Id Order_Id Name Position
1
3364
by: poohnie08 | last post by:
i have a excel spreadsheet showing staff name, date,work hour, ot hour, slot1, slot2, slot3, slot4 and others). The "()" will keep repeating from day 1 until end of month. eg in excel spreadsheet, ============================================================================== A1 |A2 A3 A4 A5 A6 A7 A8 |A9 A10 A11 | 01/02/04 |02/02/04 StaffName |Work Hr OT Hr Slot1...
1
1902
by: JBoeker | last post by:
Hello, I have 3 tables in my mdb file, one contains a list of definitions, one is a list physical items, and one is a list overrides. Normally my query will join the definition physical item tables, sharing an id number (e.g. in my defintion file I may have a table item and its price, item number, etc; in my physical item table I may list sales date, purchaser etc; the query result will combine these). Sometimes I would like to...
3
1667
by: Hyphessobricon | last post by:
Hallo, Indeed, a count of a query with a group by function gives more records than there are and so for-next structures don't function. How is this to be mended. Anyone? Everyone in fact. Answers are greatly appreciated. -- mvg Hyphessobrycon
6
2781
by: gerbski | last post by:
Hi all, I am relatively new to ADO, but up to now I got things working the way I wanted. But now I've run into somethng really annoying. I am working in MS Access. I am using an Access frontend separately from a backend. The tables from the backend database are linked in the frontend database. In the frontend there is a Form with a listbox in it. The listbox rowsource is a query that selects all the records from a (linked)
4
12454
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is this: can Access create the document and place it as an OLE object to the relevant table? Any help is greatly appreciated. Ricky
2
4235
by: dauwe.peter | last post by:
A table : Nameperson, Book nr, Bookdatein, Bookdateout, CD nr, cddatein, cddateout, dvd nr, dvddatein, dvddateout. I would like a query where a see the personsname en de last book with the datein and out , the last cd with datein and out , and the same for the dvd. Because the last time the person came he toke only a book but dit not return his dvd (for example). But with one click i would like to see the last of every item with the...
9
3639
by: Sinner | last post by:
Hi, I have a field name 'USER' in tableMAIN. How do I replace the user names with corresponding user names. I can do that in xl using vlookup but now I'm trying to find a way to do that in access. For a user mismatch, it should give NA Thx.
0
9703
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
9566
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
10555
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
10300
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
6844
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5503
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...
0
5636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4277
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
3
2974
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.