I had to split a database and there is now a problem with the code. I have found by researching online that you cannot use “Seek” in a split database and that is my problem. The suggested fix is using “FindFirst” instead. However, I am not very good with writing code so I am having issues in getting it right. The code is attached to the “After Update” property of a combo box that reads off a table that is now linked. When you click in the combo box it gives you a drop down list of Cities/Provinces/County. When you select the one you want it populates that box and the two below it with the City, Province, and County. I have posted the original code below and then what I have tried to do. Any suggestion?
Old Code:
My Attempt: Which does not work.
Old Code:
Code:
Private Sub Source_City_AfterUpdate()
'If user chooses a city from the list, automatically fill in the corresponding
'province and country fields
Dim db As Database
Dim CityList As Recordset
Set db = CurrentDb()
Set CityList = db.OpenRecordset("CityProvCountryLookup")
CityList.Index = "City"
CityList.Seek "=", Screen.ActiveControl
DoCmd.GoToControl "[Source Postal Code]"
CityList.Close
Set CityList = Nothing
db.Close
Set db = Nothing
End Sub
Code:
Private Sub Source_City_AfterUpdate()
'If user chooses a city from the list, automatically fill in the corresponding
'province and country fields
Dim db As Database
Dim CityList As Recordset
Set db = CurrentDb()
Set CityList = db.OpenRecordset("CityProvCountryLookup")
CityList.FindFirst City & "=" & Screen.ActiveControl
DoCmd.GoToControl "[Source Postal Code]"
CityList.Close
Set CityList = Nothing
db.Close
Set db = Nothing
End Sub
Comment