Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2002

    Unanswered: Populate a combo box with filtered query

    It'd be best if I explain the problem with an example:
    1. I have the following tables and relevant fields:

    lngORGID /* Primary Key, autonumbered */

    lngORGADDRESSID /* Primary Key, autonumbered */
    lngORGID /*linked with tblORGANIZATIONS */
    txtORGADDRESSTYPE /* linked with a look-up
    named tblORGADDRESSTYPES */

    /* Something to note: each organization can have multiple addresses. */

    lngPEOPLEID /* Primary Key, autonumbered */

    lngORGCONTACTID /* Pimrary Key, autonumbered *?

    2. I use a single form for entering a person's organization contact info. On this form, I have a ComboBox lngORGID which I use for filling in the lngORGID thus effectively stating what organization the person works for.

    There is another ComboBox further down for lngORGADDRESSID. Here's my problem. Once I have assigned the person to a particular organization, I only want the addresses associated with that organization to appear in the PersonsOrgAddress ComboBox instead of all of the lngORGADDRESSIDs in tblORGADDRESSES.

    In other words, when I start this single OrgContact record for the person, the PersonsOrg ComboBox contains all of the ORGIDs. Also, the PersonsOrgAddress ComboBox is initialized to contain all of the ORGADDRESSIDs. What I want is that, as soon as the user selects an ORGID in the PersonsOrg ComboBox and then exits that combobox, then the
    PersonsOrgAddress ComboBox immediately gets filtered down to only the ORGADDRESSES belonging to the selected organization.

    Not sure exactly what to do....

    Any suggestions? I've combed through many books for hours and nothing exactly matches what I want...

    Any assistance would be greatly appreciated!

  2. #2
    Join Date
    Mar 2002
    in the "before update" or "after update" event of your organization ID field, you'll need ot attach code.
    that sets the rowsource of your addressfield on the fly.

    for example...

    Public sub Before_Update ()
    OrganizationAddress.Rowsource = "SELECT * FROM tblOrganizationAddresses WHERE OrganizationAddressesOrganizationID = " & OrganizationID.Value

    End sub

Posting Permissions

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