SQL Examples for VB/Database Retrieval
Click here to download the form, the project, the database
Modify the datCities.DatabaseName property to point to your location of the CityCountry database

Private Sub cmdFind_Click()

Dim nom As String, criteria As String
lstCities.Clear

If txtCountry.Text <> "" Then

Let nom = txtCountry.Text
Let criteria = "country = " & "'" & nom & "'"
datCities.Recordset.FindFirst criteria
Do While datCities.Recordset.NoMatch = False


lstCities.AddItem datCities.Recordset.Fields("city").Value
datCities.Recordset.FindNext criteria

Loop
If lstCities.ListCount = 0 Then lstCities.AddItem "None"

Else

MsgBox "You must enter a country.", , ""
txtCountry.SetFocus

End If

End Sub

Created and last updated by DrB on 02/18/09