Combo box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

Is is possible to restrict records in a combo box, based on a text box that
is automatically populated?

This is my situation.

I have a list box in a form. When you click on one of the Systems in the
list box, and click the open button, the Systems Form opens up, listing the
System ID, and the Primary Systems name.

I have a combo box in the Systems Form, that list all the communitites under
that system. I want to be able to restrict the communities in comb box. I
want to only have the communities under that specified Primary System or
System ID to be listed.

I am new to Access and really new to VB programming. Is this possible? Any
suggestions would be helpful.

Thanks
 
Trini Gal

If you are saying that you want the combo box filtered by the selection made
in the list box, that's quite do-able.

Open the query on which your combo box is based. Under the field for
System, in the criterion "cell", put something like the following (your
syntax may vary):

Forms!YourFirstForm!YourListBox

so the combo box is pointed at the choice in the listbox on your form.

Your listbox will have to have the first field/column be the ID (or the same
field value that you'd use to filter your combo box).

In your form that opens after selection in the listbox, you'll need to be
sure that the combo box is (re-)queried, to refresh it (so its query looks
at the listbox selection).

Good luck

Jeff Boyce
<Access MVP>
 
Jeff,

Thanks that helped, but not quite. When I click on the communities, only
the P_Community (Primary Community) is being displayed. Also, in the table,
the S_Community is being populated by the P_Community.

HELP!!!
 
Is there a chance your tables include a "lookup" data type for one of the
fields involved? This would mean that what is stored and what is displayed
would not be the same, and it could mess with your query.

Have you tried "hard coding" a query to see if you can get that part
working? Instead of the Forms!... that I mentioned earlier, use an actual
value as the criterion and run the query. Do you get what you expect?

Good luck

Jeff Boyce
<Access MVP>
 
Jeff,

You were right, I did have a "lookup" data type for the S_Community in my
table. I changed it to a text box. I also changed it to a combo box in my
form and it worked.

Thank you so much for all your helped. I really appreciated it.
 
Back
Top