Relative Content

Tag Archive for sqlvbams-access

VBA object variable not being recognized

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.

VBA loop won’t execute SQL statement at MoveNext

SQL tests fine outside the loop, not in the loop. Table c has 4 comments in the “CMT” field. Table k has a list of 2 keywords in the “KEY” field. The loop tests each of the comments for existence of the keyword then if exists, stores the Refnum and keyword in Table Mariners. The Do Until c.EOF loops through each comment. The For Each loops through each of the keywords “kk” in the Keywords table. The SQL should UPDATE the mariner table WHERE the comment (long field) contains the keyword (using LIKE). Without the two loops, the SQL statement works fine (using fixed word vs. variable). The error says Sub or Function not defined and highlights MOVENEXT. My MoveNext moves through each of the comments and is placed just before the LOOP. What am I missing. This is the last obstacle I am running into. Image of error attached, and code below.