Hello All,
I have a form-subform situation. The subform, which is in datasheet view, contains two dropdown boxes, Country and District (1-n). I want the district dropdown to only display records based on what's selected in the country dropdown. There will only ever be any content in District if one country is selected (let's say country 'A').
I've used the code below (one of many attempts!) to try to achieve this, but it doesn't seem to have the effect I want. It seems that if I select country 'A' from the country dropdown, the District rowsource is as expected for that particular record.
However, the rowsource for every other District in the list of records in the subform also now has the same rowsource even where the country <> A.
Similarly, if I select <>A from Country, the rowsource fro every district is now empty, even if the country selected in another row is A.
I'm sure that this is problem that has been accounted before. Is there a workaround?
Thanks for any help.
[VBA]
Dim strSQL As String
strSQL = "SELECT DistrictID, District, DistrictOrder "
strSQL = strSQL & "FROM tblDistrict "
strSQL = strSQL & "WHERE CountryID = " & Me.cmbCountryID & " "
strSQL = strSQL & "ORDER BY DistrictOrder"
Me.cmbDisctrictID.RowSource = strSQL
[/VBA]
I have a form-subform situation. The subform, which is in datasheet view, contains two dropdown boxes, Country and District (1-n). I want the district dropdown to only display records based on what's selected in the country dropdown. There will only ever be any content in District if one country is selected (let's say country 'A').
I've used the code below (one of many attempts!) to try to achieve this, but it doesn't seem to have the effect I want. It seems that if I select country 'A' from the country dropdown, the District rowsource is as expected for that particular record.
However, the rowsource for every other District in the list of records in the subform also now has the same rowsource even where the country <> A.
Similarly, if I select <>A from Country, the rowsource fro every district is now empty, even if the country selected in another row is A.
I'm sure that this is problem that has been accounted before. Is there a workaround?
Thanks for any help.
[VBA]
Dim strSQL As String
strSQL = "SELECT DistrictID, District, DistrictOrder "
strSQL = strSQL & "FROM tblDistrict "
strSQL = strSQL & "WHERE CountryID = " & Me.cmbCountryID & " "
strSQL = strSQL & "ORDER BY DistrictOrder"
Me.cmbDisctrictID.RowSource = strSQL
[/VBA]