I have set DIM k as recordset and I have set DIM kk as field. I set k = as table “keywords” and I set kk to the field “key”. I now want to loop through table k and compare each record of field kk to my SQL string. I keep getting an Object Required error 424. I thought I have defined all my objects. Here is code and image.
Private Sub Command0_Click()
Dim k As DAO.Recordset
Dim kk As Field
Set k = CurrentDb.OpenRecordset("keywords")
Set kk = Keywords.Fields(key)
For Each kk In k.Fields
Dim sql As String
sql = "UPDATE Comments LEFT JOIN Mariners ON Comments.RefNum = Mariners.Refnum " & _
" SET Mariners.KW Like '* kk *'"
DoCmd.RunSQL sql
Next
End Sub
424 Error for above code
I can’t find where I did not specify an object. I have my recordset and field, and I’m looping on the field kk to run my SQL. I’m missing something simple I suspect, and just can’t see it.
dCharles is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.