error 3061

Simba

Registered User.
Local time
Yesterday, 22:14
Joined
Mar 11, 2010
Messages
12
I have a form, in which, when the user enters the zipcode, it should obtain the relevant city, state and county from the table.

After entering the zipcode, it gives out an error 3061 and highlights as below:

Set rstAny = dbAny.OpenRecordset(strSQL, dbOpenDynaset, dbSeeChanges)




The fullcode is as below.


Private Sub txtZipCode_AfterUpdate()
Dim strSQL As String
Dim dbAny As DAO.Database
Dim rstAny As DAO.Recordset
strSQL = "SELECT Z.City, Z.StateCode, C.CountyCode, C.PrimaryPOPArea " & _
"FROM ZIPCodes As Z INNER JOIN ZipToCountyLink As C " & _
"ON Z.ZIPCode = C.ZIPCODE " & _
"WHERE Z.ZIPCode=" & Chr(34) & Me.txtZipCode & Chr(34) & _
" ORDER BY C.PrimaryPOPArea Asc"

Set dbAny = CurrentDb()
Set rstAny = dbAny.OpenRecordset(strSQL, dbOpenDynaset, dbSeeChanges)

If rstAny.RecordCount > 0 Then
rstAny.MoveLast
rstAny.MoveFirst

Me.txtCity = rstAny!City
Me.txtState = rstAny!StateCode

End If
End Sub


Kindly help me in solving this problem.
 
That generally means you have misspelled something.
 

Users who are viewing this thread

Back
Top Bottom