Cascading Combo box Code

M

Mike Busch

I posed the question about tutorials for creating a cascading combo box. I
was directed to a site and now understand the process. Created a table with
the fields suggested from the tutorial.The code is as follows.
Private Sub cboCountry_AfterUpdate()

On Error Resume Next
' Synchronise country combo with existing city
cboCountry = DLookup("[Country]", "tblAll",
"[City]='" & cboCity.Value & "'")
' Synchronise city combo with existing city
cboCity.RowSource = "Select tblAll.City " & _
"FROM tblAll " & _
"WHERE tblAll.Country = '" & cboCountry.Value & "' " & _
"ORDER BY tblAll.City;"
End Sub
I need to not have duplicated city's come up per the county. Is there some
code within the present code to make all the selections of the city's unique.
Thank you in advance.
 
A

Allen Browne

Add a DISTINCT to the RowSource:
cboCity.RowSource = "Select DISTINCT tblAll.City ...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top