Link to home
Start Free TrialLog in
Avatar of Stephen
Stephen

asked on

Access VBA Findfirst Bookmark

Hello

Can anyone tell me why the following is returning 3070

"?" not recognised as valid field name or expression.

rs.FindFirst strFind
   Dim nodX As MSComctlLib.Node

   Dim strBook As String
    Do While Not rs.NoMatch
      Set nodX = tv.Nodes.Add(, , , rs!Stockcode)
      nodX.Bold = True
      strBook = rs.Bookmark
      addChildren tv, nodX, rs, rs!Stockcode
      rs.Bookmark = strBook
   rs.FindNext strBook
   Loop

Open in new window

Avatar of Dale Fye
Dale Fye
Flag of United States of America image

What are you trying to accomplish?

This syntax is a little strange for building a treeview.  Why does your loop have the rs.NoMatch in the While statement?

Normally, you would create a recordset, loop through the recordset, and use the AddChildren routine to add subnodes but with your While statement and the preceding FindFirst, I'm totally confused.

Dale
Actually in which line do you have this error messsage?
And please provide the code snippet about setting your object instance rs.
Avatar of Stephen
Stephen

ASKER

The error occurs at line 10.



strSQL = "SELECT UnionQuery2.ID, UnionQuery2.StockCode, UnionQuery2.Description, dbo_BC.HeaderID " & _
         "FROM dbo_BC INNER JOIN UnionQuery2 ON dbo_BC.StockCode = UnionQuery2.StockCode;"

    Set rs = db.OpenRecordset(strSQL)

Open in new window

Your referenced "Line 10" is not the same Line 10 in your posted code.

Take a few minutes to properly form your question, and show us the actual code you're using.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.