M
me
I need help on the correct sql-syntax, in a loop to process one recordset by
a number from another recordset.
In testing before buiding the loop, I cannot get the sql right. Only the
last strSQL gives the desired results. What is the correct sql to implement
a variable like rstValid!lngItemID for lngItemID and not a fixed number? I
keep getting error 3061.
Thanks
Sub test()
Dim db As DAO.Database
Dim rstValid As DAO.Recordset
Dim rstTemp As DAO.Recordset
Dim strSQL As String
Dim lngTemp As Long
Set db = DBEngine(0)(0)
Set rstValid = db.OpenRecordset("tblValid")
lngTemp = rstValid!lngItemID
' strSQL = "SELECT * FROM tblBig where tblBig.lngItemID = 15073395"
' strSQL = "SELECT tblBig.lngIndex FROM tblBig INNER JOIN tblValid ON
tblBig.lngItemID = tblValid.lngItemID WHERE (([tblBig]![lngItemID] =
lngTemp))"
' strSQL = "SELECT tblBig.lngIndex FROM tblBig INNER JOIN tblValid ON
tblBig.lngItemID = tblValid.lngItemID WHERE (((tblValid.lngItemID) =
rstValid.lngItemID))"
strSQL = "SELECT tblBig.lngIndex FROM tblBig INNER JOIN tblValid ON
tblBig.lngItemID = tblValid.lngItemID WHERE (((tblValid.lngItemID) =
15073395))"
Set rstTemp = db.OpenRecordset(strSQL)
End Sub
a number from another recordset.
In testing before buiding the loop, I cannot get the sql right. Only the
last strSQL gives the desired results. What is the correct sql to implement
a variable like rstValid!lngItemID for lngItemID and not a fixed number? I
keep getting error 3061.
Thanks
Sub test()
Dim db As DAO.Database
Dim rstValid As DAO.Recordset
Dim rstTemp As DAO.Recordset
Dim strSQL As String
Dim lngTemp As Long
Set db = DBEngine(0)(0)
Set rstValid = db.OpenRecordset("tblValid")
lngTemp = rstValid!lngItemID
' strSQL = "SELECT * FROM tblBig where tblBig.lngItemID = 15073395"
' strSQL = "SELECT tblBig.lngIndex FROM tblBig INNER JOIN tblValid ON
tblBig.lngItemID = tblValid.lngItemID WHERE (([tblBig]![lngItemID] =
lngTemp))"
' strSQL = "SELECT tblBig.lngIndex FROM tblBig INNER JOIN tblValid ON
tblBig.lngItemID = tblValid.lngItemID WHERE (((tblValid.lngItemID) =
rstValid.lngItemID))"
strSQL = "SELECT tblBig.lngIndex FROM tblBig INNER JOIN tblValid ON
tblBig.lngItemID = tblValid.lngItemID WHERE (((tblValid.lngItemID) =
15073395))"
Set rstTemp = db.OpenRecordset(strSQL)
End Sub