Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Do Until or Do while problem 2

Status
Not open for further replies.

jpl458

Technical User
Sep 30, 2009
337
US
ACCESS 10 Windows 7

Have a large query with 37 columns that I use to fill a recordset. In order to see if the recordset had date in it I ran the following code:

BallsRs.MoveFirst
Dim N as Integer
N = 0
Do While BallsRs.EOF = False
Debug.Print BallsRs.Fields(N).Name
N = N + 1
BallsRs.MoveNext
Loop
All of the column names print in the immediate window, but I get the following error.

Run-time error '3265'
Item cannot be found in collection corresponding
to the requested name or ordinal.

I'm not sure, but it doesn't seem to be seeing the EOF.

Any help is appreciated.

jpl
 
If you only want to print the column names:
Code:
For N = 0 To BallsRs.Fields.Count - 1
  Debug.Print BallsRs.Fields(N).Name
Next

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Also, if you have an empty recordset, this line of code:

[tt]BallsRs.MoveFirst[/tt]

will error since there will be no (First, Last, any) record to move to.

To prevent that, wrap all your logic in:
[tt]
If BallsRs.BOF <> BallsRs.EOF then
...
End If[/tt]

Have fun.

---- Andy
 
I found it. I was just checking for column names thus the EOF is meaningless. It works in a For loop.
Thanks

jpl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top