If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Tables with Lookup queries
I have a library table. When entering the data for the County, I want it to
lookup from the County table and have a list to choose from. That works just fine. The next field is Municipality. I have a Municipality table for lookup, but I only want to show the Municipalities that come from the County just chosen. This is what I have, but it doesn't work. SELECT Municipalities.Municipality, Municipalities.MUNCode FROM Municipalities RIGHT JOIN Counties ON Municipalities.CTYCode = Counties.CTYCode WHERE (((Municipalities.CTYCode)=[Counties]![CTYCode])); Any help would be greatly appreciated. Thanks |
#2
|
|||
|
|||
Tables with Lookup queries
I believe you can simplify it significantly. Try this: SELECT Municipalities.Municipality, Municipalities.MUNCode FROM Municipalities WHERE Municipalities.CTYCode = forms![thenameoftheformyouare on]![thenameofyourcitycodefield]; There is really no need for the join to the city table for the condition is simply that the municipalities are part of the city chosen in your prior combo. Ron |
#3
|
|||
|
|||
Tables with Lookup queries
On Feb 20, 7:01 am, "Ron2006" wrote:
I believe you can simplify it significantly. Try this: SELECT Municipalities.Municipality, Municipalities.MUNCode FROM Municipalities WHERE Municipalities.CTYCode = forms![thenameoftheformyouare on]![thenameofyourcitycodefield]; There is really no need for the join to the city table for the condition is simply that the municipalities are part of the city chosen in your prior combo. Ron looking at it again, I am not sure I got the names correct on the WHERE clause. Basicaly, you want to limit the query of municipalities to only those that have a county that matches the combo box selection. No other tables/queries need be involved. Ron Ron |
#4
|
|||
|
|||
Tables with Lookup queries
Thank you Ron....that worked perfectly!
"Ron2006" wrote: I believe you can simplify it significantly. Try this: SELECT Municipalities.Municipality, Municipalities.MUNCode FROM Municipalities WHERE Municipalities.CTYCode = forms![thenameoftheformyouare on]![thenameofyourcitycodefield]; There is really no need for the join to the city table for the condition is simply that the municipalities are part of the city chosen in your prior combo. Ron |
Thread Tools | |
Display Modes | |
|
|