SQL Recordset ???

dynamictiger

Registered User.
Local time
Today, 00:23
Joined
Feb 3, 2002
Messages
270
I have the following code behind two forms?

Private Sub CSuburb_LostFocus()
Dim dbsMyTry As DAO.Database
Dim qdfTemp As DAO.QueryDef
Dim rstAusPostCodes As DAO.Recordset
Dim strPath As String

strPath = Form_frmManager.txtPostCodePath

Debug.Print strPath

Set dbsMyTry = OpenDatabase(strPath)



Set qdfTemp = dbsMyTry.CreateQueryDef("")

Dim txtSuburb As String
Dim txtstate As String

txtSuburb = Me.CSuburb

txtstate = Me.CState

'txtAddress = Me.txtAddress

SQLOutput "SELECT AusPostCodes.Locality, AusPostCodes.State, AusPostCodes.Pcode " & _
"FROM ausPostCodes " & _
"WHERE (((AusPostCodes.Locality)= '" & txtSuburb & "' ) and (AusPostCodes.State)= '" & txtstate & "' ); ", _
qdfTemp
' "Country = '" & strCountry & "'"
dbsMyTry.Close

End Sub
Function SQLOutput(strSQL As String, qdfTemp As DAO.QueryDef)

Dim rstAusPostCodesA As DAO.Recordset

Debug.Print strSQL

qdfTemp.SQL = strSQL

Debug.Print qdfTemp.SQL

Set rstAusPostCodesA = qdfTemp.OpenRecordset

Debug.Print strSQL

With rstAusPostCodesA

Do While Not .EOF

Me.postcode = " " & !PCode & ""

.MoveNext

Loop

.Close

End With

End Function

On one form the code runs perfectly.

On the other form the code won't run at all it is giving me a Method or Data member not found on the line Me.postcode = " " & !PCode & "" the !PCode is highlighted for the error.

Anyone know why?
 

Users who are viewing this thread

Back
Top Bottom