options on list box conditional on whats entered in another contro

Discussion in 'Microsoft Access Macros' started by Guest, Aug 8, 2007.

  1. Guest

    Guest 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
     
    Guest, Aug 8, 2007
    #1
    1. Advertisements

  2. 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 Colbourn wrote:
    > 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")
     
    Steve Schapel, Aug 9, 2007
    #2
    1. Advertisements

  3. Guest

    Guest Guest

    Re: options on list box conditional on whats entered in another co

    Thanks Steve,
    The second method worked fine!
    Tim

    "Steve Schapel" wrote:

    > 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 Colbourn wrote:
    > > 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")

    >
     
    Guest, Aug 9, 2007
    #3
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ruzanna
    Replies:
    0
    Views:
    313
    Ruzanna
    Feb 21, 2004
  2. Ruzanna
    Replies:
    1
    Views:
    354
    Douglas J. Steele
    Feb 22, 2004
  3. PG

    Whats the best method

    PG, Jun 21, 2004, in forum: Microsoft Access Macros
    Replies:
    2
    Views:
    140
    George Stevenson
    Jun 22, 2004
  4. Guest
    Replies:
    1
    Views:
    254
    Douglas J. Steele
    Dec 3, 2004
  5. Guest
    Replies:
    1
    Views:
    2,940
    Guest
    Jul 9, 2007
Loading...

Share This Page