Consulting

Results 1 to 2 of 2

Thread: Update combo box values in subform on change of value in another combo box

  1. #1

    Update combo box values in subform on change of value in another combo box

    Hello All

    I need some help and directions. I have a subform in MS Access form containing fields for Country and City. What I am trying to achieve is to change the list of values in City field on changing the value in Country field. I have written a code on Mousedown event of the City combo box to change the value list using the a query and recordsource. However while the values changes on changing the value in Country field, I am not able to select a value in the City field. Please advise.

    Thanks

  2. #2
    VBAX Expert
    Joined
    Oct 2012
    Posts
    726
    Location
    You need to say what happens when you try to select a value. Do you get an error or what?
    And if you are setting a default value through automation it would help to see the code.

    I'd probably use something like this

    Private Sub Form_Load()
        lstcity.RowSource = "SELECT Table1.city FROM Table1 WHERE Table1.country=[forms]![Form1]![lstcountry]"
    End Sub
    Private Sub Form_Current()
        lstcity.Requery
    End Sub
    Private Sub lstcountry_AfterUpdate()
        lstcity.Requery
    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
  •