options on list box conditional on whats entered in another contro

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

Guest

Hi,

I'm trying (and failing) to make the available options on a list box control
conditional on what is entered into another control (which also happens to be
a list box). I've been trying to use the macro action ApplyFilter (and have
made queries that should restrict the options in the list box) but this seems
to want to filter the records rather than the options of the list box.
The options in the list box are taken from a separate table. The query used
for the filter then applies to this table, but the macro doesn't work as
planned.

In detail the macro is as follows it is liked to the OnClick property of the
control [distict]:

Conditon [district]=Kasungu Action Apply Filter: Health facilities in
Kasungu (this is a query that applies to the table 'All Health Facilities'
and has the 'show' button ticked for the criteria Dist="K")
Conditon [district]=Lilongwe Action Apply Filter: Health facilities in
Lilongwe (this is a query that applies to the table 'All Health Facilities'
and has the 'show' button ticked for the criteria Dist="L")
Conditon [district]=Salima Action Apply Filter: Health facilities in Salima
(this is a query that applies to the table 'All Health Facilities' and has
the 'show' button ticked for the criteria Dist="S")

Can you help me?

Tim
 
Tim,

The ApplyFilter action is not the applicable action in this case.

One option would be to use SetValue actions, where you would set the
value of the RowSource property of the second listbox, to the query that
defines each district setting. In any case, you would have to use text
delimiter characters in the Condition statement, e.g.
[district]="Kasungu"

However, it would probably be a lot easier to just have one query for
the Row Source of the second listbox, and then in the criteria of the
query, instead of "hard-coding" the value, reference the value of the
first listbox, using syntax such as:
[Forms]![NameOfYourForm]![District]
.... or whatever.

Then, you can simply use a macro with one action: Requery (to apply to
the second listbox).
 
Thanks Steve,
The second method worked fine!
Tim

Steve Schapel said:
Tim,

The ApplyFilter action is not the applicable action in this case.

One option would be to use SetValue actions, where you would set the
value of the RowSource property of the second listbox, to the query that
defines each district setting. In any case, you would have to use text
delimiter characters in the Condition statement, e.g.
[district]="Kasungu"

However, it would probably be a lot easier to just have one query for
the Row Source of the second listbox, and then in the criteria of the
query, instead of "hard-coding" the value, reference the value of the
first listbox, using syntax such as:
[Forms]![NameOfYourForm]![District]
.... or whatever.

Then, you can simply use a macro with one action: Requery (to apply to
the second listbox).

--
Steve Schapel, Microsoft Access MVP

Tim said:
Hi,

I'm trying (and failing) to make the available options on a list box control
conditional on what is entered into another control (which also happens to be
a list box). I've been trying to use the macro action ApplyFilter (and have
made queries that should restrict the options in the list box) but this seems
to want to filter the records rather than the options of the list box.
The options in the list box are taken from a separate table. The query used
for the filter then applies to this table, but the macro doesn't work as
planned.

In detail the macro is as follows it is liked to the OnClick property of the
control [distict]:

Conditon [district]=Kasungu Action Apply Filter: Health facilities in
Kasungu (this is a query that applies to the table 'All Health Facilities'
and has the 'show' button ticked for the criteria Dist="K")
Conditon [district]=Lilongwe Action Apply Filter: Health facilities in
Lilongwe (this is a query that applies to the table 'All Health Facilities'
and has the 'show' button ticked for the criteria Dist="L")
Conditon [district]=Salima Action Apply Filter: Health facilities in Salima
(this is a query that applies to the table 'All Health Facilities' and has
the 'show' button ticked for the criteria Dist="S")
 
Back
Top