Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2004
    Location
    Canada
    Posts
    47

    Unanswered: Combo-Box selects. a little help

    I have 2 combo boxes on the same form,

    1. CountryID,CountryName,CountryCode
    2. StateID, StateName, CountryCode

    I want the StateName combo box to only show the States where the State.CountryCode = Country.CountryCode

    I used an AfterUpdate event to place the Country.CountryCode into a field called ScrnCC and then used the following:

    SELECT [States and Provinces].StateID, [States and Provinces].StateName FROM [States and Provinces] WHERE ((([States and Provinces].CountryName)=[ScrnCC]));

    I know Im missing something simple, so a little advice, help would be appreciated.

    Thanks

  2. #2
    Join Date
    Feb 2004
    Posts
    199
    SELECT [States and Provinces].StateID, [States and Provinces].StateName FROM [States and Provinces] WHERE ((([States and Provinces].CountryName)=[Forms]![your form name]![ScrnCC]));

    don't forget to requery the second combo after the first is updated
    MDB, ADP <-> MS SQL + VBA, ADO & RDO, .NET, Oracle, Java/Jsp.

  3. #3
    Join Date
    Mar 2004
    Location
    Canada
    Posts
    47
    Originally posted by Kakha
    SELECT [States and Provinces].StateID, [States and Provinces].StateName FROM [States and Provinces] WHERE ((([States and Provinces].CountryName)=[Forms]![your form name]![ScrnCC]));

    don't forget to requery the second combo after the first is updated
    How do I requery a combo box?

  4. #4
    Join Date
    Feb 2004
    Posts
    199
    1) bind second combo to SQL I've written
    2) in AfterUpdate event of 1st combo write the code

    [Second Combo Name].requery

    you don't need to change second combo's rowsource durring runtime (as you tried)
    MDB, ADP <-> MS SQL + VBA, ADO & RDO, .NET, Oracle, Java/Jsp.

Posting Permissions

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