473,473 Members | 4,176 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Multiple Records from Multiple Fields

I have a membership table (tAllRecs), with each member assigned a unique
number (fMbrNo).
I have an event table (tWalks), with each event assigned a unique number
(fWalkNo).
Each event has 7 leaders (fLdr1, fLdr2,…), and 7 assistant leaders (fALdr1,
ALdr2,…). The fLdr and fALdr fields contain the tAllRecs.fMbrNo for each of
the 14 total leaders and assistants.
For each event (record) in tWalks, I have to print data that exists in
tAllRecs for each leader and assistant (address, phone, etc.).
This is where I am confused, because what I need to do is look up 14 fields
in tWalks, and print the corresponding data that exists in tAllRecs for each
of the leaders and assistants. In other words, each of the 14 fields of
interest in a single record of tWalks points to 14 separate records in
tAllRecs.
Any thoughts how to do this? I am likely making this more difficult than
necessary. Thanks for any insight.

Rob B.
Oct 6 '07 #1
6 1640
You have a normalization problem
there ought to be a seperate join table for Leaders assigned to Walks (With
a Boolean Field To seperate leader "types")
I Suggest, if you *own* the db to do that

MbrWalks
--------
fMbrNo (FK)
fWalkNo (FK)
IsLeader Boolean

HtH

Pieter
"Rob B." <no****@use.netwrote in message
news:fe********@news2.newsguy.com...
>I have a membership table (tAllRecs), with each member assigned a unique
number (fMbrNo).
I have an event table (tWalks), with each event assigned a unique number
(fWalkNo).
Each event has 7 leaders (fLdr1, fLdr2,.), and 7 assistant leaders
(fALdr1,
ALdr2,.). The fLdr and fALdr fields contain the tAllRecs.fMbrNo for each
of
the 14 total leaders and assistants.
For each event (record) in tWalks, I have to print data that exists in
tAllRecs for each leader and assistant (address, phone, etc.).
This is where I am confused, because what I need to do is look up 14
fields
in tWalks, and print the corresponding data that exists in tAllRecs for
each
of the leaders and assistants. In other words, each of the 14 fields of
interest in a single record of tWalks points to 14 separate records in
tAllRecs.
Any thoughts how to do this? I am likely making this more difficult than
necessary. Thanks for any insight.

Rob B.

Oct 6 '07 #2
You can however get the data you're after by using a Series of UNION Queries
SELECT fWalkNo, fldr1, -1 As IsLeader FROM tWalks
UNION ALL
SELECT fWalkNo, fldr2, -1 FROM tWalks
UNION ALL
SELECT fWalkNo, fldr3, -1 FROM tWalks
.....
UNION ALL
SELECT fWalkNo, FAldr7,0 FROM tWalks

Which also can be used to create the join table ...

HtH

Pieter

"Rob B." <no****@use.netwrote in message
news:fe********@news2.newsguy.com...
>I have a membership table (tAllRecs), with each member assigned a unique
number (fMbrNo).
I have an event table (tWalks), with each event assigned a unique number
(fWalkNo).
Each event has 7 leaders (fLdr1, fLdr2,.), and 7 assistant leaders
(fALdr1,
ALdr2,.). The fLdr and fALdr fields contain the tAllRecs.fMbrNo for each
of
the 14 total leaders and assistants.
For each event (record) in tWalks, I have to print data that exists in
tAllRecs for each leader and assistant (address, phone, etc.).
This is where I am confused, because what I need to do is look up 14
fields
in tWalks, and print the corresponding data that exists in tAllRecs for
each
of the leaders and assistants. In other words, each of the 14 fields of
interest in a single record of tWalks points to 14 separate records in
tAllRecs.
Any thoughts how to do this? I am likely making this more difficult than
necessary. Thanks for any insight.

Rob B.

Oct 6 '07 #3
I would likely better understand your response if I better understood Access
and SQL. Thank you for trying, though!

The task of transposing 14 fields in one record to 14 separate records seems
more difficult than I thought. For my purposes, there is no need to
distinguish between Leaders and Assistants, so I have not used the ISLEADER
Boolean field as you suggest. This is what I did

SELECT fWalkNo, fLdr1 FROM tblWalks
UNION ALL
SELECT fWalkNo, fLdr12 FROM tblWalks
UNION ALL
SELECT fWalkNo, fLdr13 FROM tblWalks
UNION ALL;

When I try the below query, Access tells me it is an, "Invalid SQL
statement; expected DELETE, INSERT, PROCEDURE, SELECT, or UPDATE", so I am
still stuck. Are you trying to tell me to create 14 separate UNION queries?
On 6-Oct-2007, "Pieter Wijnen"
<it*********************************************** ***********@online.replace.with.norway>
wrote:
You can however get the data you're after by using a Series of UNION
Queries
SELECT fWalkNo, fldr1, -1 As IsLeader FROM tWalks
UNION ALL
SELECT fWalkNo, fldr2, -1 FROM tWalks
UNION ALL
SELECT fWalkNo, fldr3, -1 FROM tWalks
....
UNION ALL
SELECT fWalkNo, FAldr7,0 FROM tWalks

Which also can be used to create the join table ..
Oct 7 '07 #4
On Sun, 7 Oct 2007 04:33:53 GMT, "Rob B." <no****@use.netwrote:
>The task of transposing 14 fields in one record to 14 separate records seems
more difficult than I thought. For my purposes, there is no need to
distinguish between Leaders and Assistants, so I have not used the ISLEADER
Boolean field as you suggest. This is what I did

SELECT fWalkNo, fLdr1 FROM tblWalks
UNION ALL
SELECT fWalkNo, fLdr12 FROM tblWalks
UNION ALL
SELECT fWalkNo, fLdr13 FROM tblWalks
UNION ALL;

When I try the below query, Access tells me it is an, "Invalid SQL
statement; expected DELETE, INSERT, PROCEDURE, SELECT, or UPDATE", so I am
still stuck. Are you trying to tell me to create 14 separate UNION queries?
The problem here is the final UNION ALL;

You're saying to UNION the thirteen queries above with... nothing at all. It's
like an English sentence "I'd like vanilla ice cream and peaches and chocolate
sauce and." It's ungrammatical!

Just remove the last UNION ALL, or add the fourteenth field name.

John W. Vinson [MVP]
Oct 7 '07 #5
<slapping self on side of head>

Duh!

Thanks. Everything is working as expected, now.
Rob B.
On 7-Oct-2007, John W. Vinson <jvinson@STOP_SPAM.WysardOfInfo.comwrote:
You're saying to UNION the thirteen queries above with... nothing at all.
It's
like an English sentence "I'd like vanilla ice cream and peaches and
chocolate
sauce and." It's ungrammatical!
Oct 7 '07 #6
de nada,
sql isn't that difficult, but not that easy either

Pieter

"Rob B." <no****@use.netwrote in message
news:fe********@news2.newsguy.com...
<slapping self on side of head>

Duh!

Thanks. Everything is working as expected, now.
Rob B.
On 7-Oct-2007, John W. Vinson <jvinson@STOP_SPAM.WysardOfInfo.comwrote:
>You're saying to UNION the thirteen queries above with... nothing at all.
It's
like an English sentence "I'd like vanilla ice cream and peaches and
chocolate
sauce and." It's ungrammatical!

Oct 7 '07 #7

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

Similar topics

10
by: shank | last post by:
I have a recordset that contains multiple records of product a user is purchasing. For clarity, I converted the recordset fields to variables. I need to take that entire recordset and insert it...
7
by: Drew | last post by:
I have a db table like the following, UID, int auto-increment RegNo Person Relation YearsKnown Now here is some sample data from this table,
6
by: Christopher Harrison | last post by:
Is there a way to store an indefinite number of keys in one field and self join them? Imagine, for example, you have a table of users with a "friends" column. Say user 1 is friends with users 9, 7,...
2
by: news.hp.com | last post by:
I have situation where I need to copy multiple records (only certain fields) from a Rules table to an Events table based on a selection identified in a combo box. When the selection is made in a...
5
by: JP SIngh | last post by:
Hi All This is a complicated one, not for the faint hearted :) :) :) Please help if you can how to achieve this search. We have a freetext search entry box to allow users to search the...
1
by: NumberCruncher | last post by:
Hi All, I am struggling with setting up my first system of tables, forms,and reports, and could use your help! I am setting up a database to keep track of the production of a produced item. The...
52
by: MP | last post by:
Hi trying to begin to learn database using vb6, ado/adox, mdb format, sql (not using access...just mdb format via ado) i need to group the values of multiple fields - get their possible...
2
by: Kosmos | last post by:
Alright so I've got this Outlook code written in VBA in Access. The first part, which works, records information about appointment times based on the required days before notification of certain...
4
4Him
by: 4Him | last post by:
First off, let me say this is a great site! I've just started working with Access and much of my success is from what I've read here! Background: I have a form, driven off a single table. Goal:...
1
by: tjm0713 | last post by:
Not sure this can be done but here is my current situation. I have a table containing millions of records. Each record has 28 fields. One of the fields I am trying to return the single record for...
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...
1
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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
muto222
php
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.