How can I code access 2010 vba to search all data tables for keywords

Need to modify code below to be able to search entire database for term in table tblSearchTerm.Term field.  


dim tbl as tabledef
dim fld as field
dim rs as recordset
for each tbl in dbEngine(0)(0).tabledefs
  for each fld in tbl.fields
    set rs = dbEngine(0)(0).OpenRecordset("Select " & fld.name & " from " & tbl.name & " Inner Join tblSearchTerms On " & fld.name & "=tblSearchTerms.Term")
    if rs.EOF then
    else
        debug.print "keywords found in table: " & tbl.name & " field: " & fld.name
    end if
  next
next
conardbAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Perhaps something like:

dim tbl as tabledef
dim fld as field
dim rs as recordset
for each tbl in dbEngine(0)(0).tabledefs
  for each fld in tbl.fields
    set rs = dbEngine(0)(0).OpenRecordset("SELECT * FROM " & tbl.name & " WHERE " & fld.Name & " IN  (SELECT * FROM tblSearchTerms)")
    if rs.EOF then
    else
        debug.print "keywords found in table: " & tbl.name & " field: " & fld.name
    end if
  next
next
0
conardbAuthor Commented:
getting type mismatch using below:

                strSQL = "SELECT * FROM " & tbl.Name & " WHERE " & fld.Name & " IN  (SELECT * FROM tblSearchTerms)"
                Set rs = DBEngine(0)(0).OpenRecordset(strSQL)
0
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
If "fld" is a Numeric field, then you can't use the IN syntax - but then you're searching for Keywords, which would exclude numeric values, so just check the fld.Type:

If fld.Type = dbText or fld.Type = dbMemo Then
  '/ create the sql here
End If
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
conardbAuthor Commented:
thanks... getting "block variable not set" on if rs.eof
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.