PDA

View Full Version : Update combo box values in subform on change of value in another combo box



Jeevie
07-13-2014, 05:41 AM
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

jonh
07-14-2014, 03:11 AM
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