Connecting Tech Pros Worldwide Forums | Help | Site Map

2 Level lookup in a table

Newbie
 
Join Date: Mar 2009
Posts: 5
#1: Mar 17 '09
Hi,

I am baffled on this one and perhaps just a bit brain dead. I have a table with two look up columns.

Structure

Departments
Dept_ID Autonum
Dept_Name Text

Groups
Group_ID Autonum
Dept_ID Num
Group_Name Text

Teams
Team_ID Autonum
Dept_ID Num
Group_ID Num
Team_Name Text

In a table=based look up for Group_ID in the table Teams, I need to limit the returned records from a query on Groups to the subset where Dept_ID equals the previously looked up Dept_ID.

I know the query is going to look something like this:

SELECT Groups.Group_ID, Groups.Group_Name
FROM Groups
WHERE (((Groups.Dept_ID)=???????))
ORDER BY Groups.Group_Name;

but how do I refer to the Dept_ID I just looked up in the row I am entering?

Thanks in advance for the help

FishVal's Avatar
Expert
 
Join Date: Jun 2007
Location: Israel
Posts: 2,584
#2: Mar 17 '09

re: 2 Level lookup in a table


Quote:

Originally Posted by dnorris View Post

....
In a table=based look up for Group_ID in the table Teams, I need to limit the returned records from a query on Groups to the subset where Dept_ID equals the previously looked up Dept_ID.
....

Hello, dnoriss.

Unfortunately, this doesn't make much sense. Could you elaborate further on it?
Example of unfiltered data and desired output would be nice as well.

Regards,
Fish.
Newbie
 
Join Date: Mar 2009
Posts: 5
#3: Mar 17 '09

re: 2 Level lookup in a table


In the table Names, I first do a look up for Dept_ID using all the available records in the table Department, then I want I do a look up for Group_ID where I limit the rows displayed from the table Groups where Groups.Dept_ID equals the value Dept_ID for the row I am currently entering.

I can do this in a form, but I would like to build this into the design for the Table Names.
FishVal's Avatar
Expert
 
Join Date: Jun 2007
Location: Israel
Posts: 2,584
#4: Mar 17 '09

re: 2 Level lookup in a table


What is table [Names] ?
Newbie
 
Join Date: Mar 2009
Posts: 5
#5: Mar 18 '09

re: 2 Level lookup in a table


Du'h

I meant the Teams table
FishVal's Avatar
Expert
 
Join Date: Jun 2007
Location: Israel
Posts: 2,584
#6: Mar 18 '09

re: 2 Level lookup in a table


Well.

What does mean "I first do a look up for Dept_ID using all the available records in the table Department"?
Does it mean table [Teams] could contain Dept_ID values not matching those in [Departments] table? How do you perform this "look up"?

What the second "look up" means?
Does it mean the desired records are those where [Dept_ID]/[Group_ID] combination match that in [Groups] table?
If so, then why would you need 2 level filtering?
Does it mean [Groups] table could contain [Dept_ID] not matching any in [Departments] table?
Newbie
 
Join Date: Mar 2009
Posts: 5
#7: Mar 18 '09

re: 2 Level lookup in a table


It the table design view, there is a 'lookup' tab for each field that allow a listbox to display the rows from a table or query.

When a user is entering/editing a row in Teams, they first choose Dept_ID from a listbox of all rows in Departments (I have that working). Then then choose Group_ID from a listbox of all rows in Groups where Groups.Dept_ID equals the value of Dept_ID in the current rows (this is what is not working).

How do I get the value of Dept_ID for the current row (in Teams) into the WHERE clause in the Lookup associated with the field Teams.Group_ID?
FishVal's Avatar
Expert
 
Join Date: Jun 2007
Location: Israel
Posts: 2,584
#8: Mar 18 '09

re: 2 Level lookup in a table


It won't work anyway in "table view".
Read Cascading Combo/List Boxes howto to get it working in form.
Newbie
 
Join Date: Mar 2009
Posts: 5
#9: Mar 18 '09

re: 2 Level lookup in a table


I knew how to get it working in a form.

Thank you.
Reply

Tags
lookup, query, tables