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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

displaying field name

Status
Not open for further replies.

grmman

MIS
Sep 9, 2003
81
US
I have a table with 120 fields. I am running this small function just to print out the name of each field.
When it gets to the 57 one it stops and give me an error "run time error 3021" no current record"
when I restart the function at 58 it goes to record 114.
Its only doing 57 records at a time.
Can anyone let me know if they see anything wrong with this

thanks

Code:
Function check_results()
Dim rst As Recordset
Dim db As Database
Set db = CurrentDb
Dim x As Double
Set rst = db.OpenRecordset("select * from tblresults")
rst.MoveLast
rst.MoveFirst
x = 0
MsgBox rst.Fields.Count
Do While x < rst.Fields.Count
    
    Debug.Print rst.Fields(x).Name
    x = x + 1
    rst.MoveNext
 Loop
 

End Function
 
Get rid of the rst.MoveNext ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
If you're only printing the field names, there's no need to loop the recordset. Use

[tt]for x = 0 to rst.fields.count-1
debug.print rst.fields(x).name
next x[/tt]

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top