Listbox selection limited by current form record

M

mt_pelion

An example of what I am trying to do is this:
I have a Table for States, Cities, and Streets
I have a States Form that allows you to select a single State and see info
on it.
I would like to have 2 list boxes on this form.
The first list box would only show available Cities in the currently
selected State record and would change based on whichever State was the
active record.
The second list box would only show available Streets in the City selected
in the first box.
From there, a subform would show the crew assigned to that street.
I do not want more than one option selected at a time in either list box.

Thanks!
 
K

Klatuu

Any reason to use List Boxs rather than Combo boxes?
The Cascading combo box technique works with List Boxes as well. If you are
not familiar with this, the way it is done is to filter Combo2's row source
query on the value in Combo1 and filter Combo3's row source query on the
value in Combo2.

To refresh the list, you requery the downstrean combos in the After Update
event of the combo. That is, in Combo1, requery combo2 and combo3 and in
Combo2, requery combo3.
 
M

mt_pelion

My only reason for using the List box was because I am under the impression
that a combo box only shows the currently selected option as opposed to all
available options (which is what I want to be able to see). Is that correct?
 
M

mt_pelion

Also, I appear to be doing something wrong in my selection. I currently have
this:
SELECT [City].[ID], [City].[CityName] FROM [City] WHERE
((([City].[State])=[Forms]![Frm StateForm]![StateName])) ORDER BY
[City].[CityName];
 
K

Klatuu

If that is what you want, a List Box is fine.
You don't say what the problem is with the query.
--
Dave Hargis, Microsoft Access MVP


mt_pelion said:
Also, I appear to be doing something wrong in my selection. I currently have
this:
SELECT [City].[ID], [City].[CityName] FROM [City] WHERE
((([City].[State])=[Forms]![Frm StateForm]![StateName])) ORDER BY
[City].[CityName];

mt_pelion said:
My only reason for using the List box was because I am under the impression
that a combo box only shows the currently selected option as opposed to all
available options (which is what I want to be able to see). Is that correct?
 
M

mt_pelion

Sorry! The problem is that Access tells me that the expression is typed wrong
or too complex.

Klatuu said:
If that is what you want, a List Box is fine.
You don't say what the problem is with the query.
--
Dave Hargis, Microsoft Access MVP


mt_pelion said:
Also, I appear to be doing something wrong in my selection. I currently have
this:
SELECT [City].[ID], [City].[CityName] FROM [City] WHERE
((([City].[State])=[Forms]![Frm StateForm]![StateName])) ORDER BY
[City].[CityName];

mt_pelion said:
My only reason for using the List box was because I am under the impression
that a combo box only shows the currently selected option as opposed to all
available options (which is what I want to be able to see). Is that correct?

:

Any reason to use List Boxs rather than Combo boxes?
The Cascading combo box technique works with List Boxes as well. If you are
not familiar with this, the way it is done is to filter Combo2's row source
query on the value in Combo1 and filter Combo3's row source query on the
value in Combo2.

To refresh the list, you requery the downstrean combos in the After Update
event of the combo. That is, in Combo1, requery combo2 and combo3 and in
Combo2, requery combo3.
--
Dave Hargis, Microsoft Access MVP


:

An example of what I am trying to do is this:
I have a Table for States, Cities, and Streets
I have a States Form that allows you to select a single State and see info
on it.
I would like to have 2 list boxes on this form.
The first list box would only show available Cities in the currently
selected State record and would change based on whichever State was the
active record.
The second list box would only show available Streets in the City selected
in the first box.
From there, a subform would show the crew assigned to that street.
I do not want more than one option selected at a time in either list box.

Thanks!
 
K

Klatuu

That means there is something wrong with the query, but I don't see the problem
--
Dave Hargis, Microsoft Access MVP


mt_pelion said:
Sorry! The problem is that Access tells me that the expression is typed wrong
or too complex.

Klatuu said:
If that is what you want, a List Box is fine.
You don't say what the problem is with the query.
--
Dave Hargis, Microsoft Access MVP


mt_pelion said:
Also, I appear to be doing something wrong in my selection. I currently have
this:
SELECT [City].[ID], [City].[CityName] FROM [City] WHERE
((([City].[State])=[Forms]![Frm StateForm]![StateName])) ORDER BY
[City].[CityName];

:

My only reason for using the List box was because I am under the impression
that a combo box only shows the currently selected option as opposed to all
available options (which is what I want to be able to see). Is that correct?

:

Any reason to use List Boxs rather than Combo boxes?
The Cascading combo box technique works with List Boxes as well. If you are
not familiar with this, the way it is done is to filter Combo2's row source
query on the value in Combo1 and filter Combo3's row source query on the
value in Combo2.

To refresh the list, you requery the downstrean combos in the After Update
event of the combo. That is, in Combo1, requery combo2 and combo3 and in
Combo2, requery combo3.
--
Dave Hargis, Microsoft Access MVP


:

An example of what I am trying to do is this:
I have a Table for States, Cities, and Streets
I have a States Form that allows you to select a single State and see info
on it.
I would like to have 2 list boxes on this form.
The first list box would only show available Cities in the currently
selected State record and would change based on whichever State was the
active record.
The second list box would only show available Streets in the City selected
in the first box.
From there, a subform would show the crew assigned to that street.
I do not want more than one option selected at a time in either list box.

Thanks!
 
J

John W. Vinson

Sorry! The problem is that Access tells me that the expression is typed wrong
or too complex.

Try explicitly specifying the parameter:

PARAMETERS [Forms]![Frm StateForm]![StateName] Text;
SELECT [City].[ID], [City].[CityName] FROM [City] WHERE
((([City].[State])=[Forms]![Frm StateForm]![StateName])) ORDER BY
[City].[CityName];
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top