Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Posts
    2

    Unanswered: Conditional actions with multiple tables

    I have a form which is connected to one main database. There are two fields in this form. One is Issue and one is Sub-Issue. When I pick an Issue from the drop down menu, I want the sub-issue to change accordingly. How do I do this?

    -running access 2002.

    thanks!

  2. #2
    Join Date
    Nov 2003
    Posts
    267
    You write you second query (the one listed as the rowsource inthe second combo box) to be based on a seelction in the fisrt combo box. The in the after_update event of the first combo box you include the code:

    Me.ComboboxTwo.requery


    The will refresh the query in the second combo box to be based on the current selection like you are wishing

    S-

  3. #3
    Join Date
    Jun 2003
    Location
    USA
    Posts
    1,032
    Here is a way to have a second combo box (perhaps listing products) based on another combo box (perhaps listing companies). Thus after the user chooses a company, he then sees only the products for that company in the second combo box.

    For criteria in the 2nd combo box (and to get to the query design mode of the combo box click on the 3 dots just to the right of the combo box's RowSource property):
    Like [Forms]![MyForm]![MyFirstComboBox]

    And for the OnEnter property of the 2nd combo box:
    =ctlRequery()

    And in any module:
    Public Function ctlRequery()
    ' Purpose: Use this in OnEnter property of a combobox that's based on another control
    ' that may have changed or based on records that may have changed
    ' since the form was first opened.

    On Error GoTo Err_ctlRequery

    ' Dim var.
    Dim ctl As Control

    ' Set var.
    Set ctl = Screen.ActiveControl

    ' Requery control.
    ctl.Requery

    Exit Function

    Err_ctlRequery:
    Exit Function

    End Function

    For an example of dependent combo boxes you can download my sample invoices database currently at http://www.bullschmidt.com/access and then on the Invoices Dialog check out the Invoice # combo box which is based on the Rep # combo box.

    One related point is that you probably wouldn't want to allow blanks (i.e. Nulls) in fields that are going to be used with Like in any criteria for that field. Otherwise the blanks wouldn't be shown.
    J. Paul Schmidt, Freelance Web and Database Developer
    www.Bullschmidt.com
    Access Database Sample, Web Database Sample, ASP Design Tips

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •