By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,671 Members | 1,280 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,671 IT Pros & Developers. It's quick & easy.

Can't see some data in VBA recordset

P: 2
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!SomeField 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
Mar 11 '08 #1
Share this Question
Share on Google+
2 Replies


Expert Mod 2.5K+
P: 2,545
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!SomeField 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:
Expand|Select|Wrap|Line Numbers
  1. Dim FieldCounter as Integer
  2. For FieldCounter = 0 to [name of recordset].fields.count - 1
  3.     Debug.Print [name of recordset].fields(FieldCounter).Name
  4. Next I
-Stewart
Mar 11 '08 #2

P: 2
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
Mar 11 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.