Can't see some data in VBA recordset

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AustinK
    New Member
    • Mar 2008
    • 2

    Can't see some data in VBA recordset

    I have a query with data from several tables. I open it as a recordset in a VBA module and can get data from some of the fields with eg SomeData = TheQuery!SomeFi eld but for other fields when the code runs I get error 3626 - item not found in this collection.

    It is not a typo - the field names are correct.

    Any hints?

    Is there a way to see what it thinks is in the collection?

    Thanks
  • Stewart Ross
    Recognized Expert Moderator Specialist
    • Feb 2008
    • 2545

    #2
    Originally posted by AustinK
    I have a query with data from several tables. I open it as a recordset in a VBA module and can get data from some of the fields with eg SomeData = TheQuery!SomeFi eld but for other fields when the code runs I get error 3626 - item not found in this collection.
    ...
    Hi. This message just means that the field name you've used is not recognised as belonging to any field in that particular recordset.

    To show all field names for a recordset in the immediate window run the following segment of debug code in one of your recordset procedures:
    [code=vb]Dim FieldCounter as Integer
    For FieldCounter = 0 to [name of recordset].fields.count - 1
    Debug.Print [name of recordset].fields(FieldCo unter).Name
    Next I[/code]
    -Stewart

    Comment

    • AustinK
      New Member
      • Mar 2008
      • 2

      #3
      Thanks - that helped me to find the problem. It only listed 3 fields instead of the expected 15-odd. Working back I found I had opened a different recordset with the same name.

      My VBA is very rusty.

      AK

      Comment

      Working...