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 cmdOrderByPop_Click()
Dim strSQL As String
txtCurrency.DataField = ""
txtCurrency.Text = ""
strSQL = "SELECT * FROM Cities ORDER BY pop1995 ASC"
datCities.RecordSource = strSQL
datCities.Refresh
End Sub
Private Sub cmdQuit_Click()
End
End Sub
Private Sub cmdShowCurrency_Click()
Dim strSQL As String
Let strSQL = "SELECT city, Cities.country, " & _
"Cities.pop1995, currency " & _
"FROM Cities INNER JOIN Countries ON " & _
"Cities.country=Countries.country ORDER BY city ASC"
datCities.RecordSource = strSQL
datCities.Refresh
txtCity.DataField = "city"
txtCountry.DataField = "country"
txtPopulation.DataField = "pop1995"
txtCurrency.DataField = "currency"
End Sub
Created and last updated by DrB on 02/18/09