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

DAO - Recordset.Fields.Count

Status
Not open for further replies.

yu217171

Programmer
Aug 2, 2002
203
CA
Hi everyone, .. simple question

I run a query (select * from x) and am trying to find out how many columns are in the recordset.

I'm trying

Msgbox objRS.Fields.Count and regardless of the query I write, I always get 1.

This can't be right, can it??

Keith
 
So I assume you got the issue in thread702-768174 straightened out. Try moving to the last record to get the full count of your recordset. i.e. rst.MoveLast then do a count
 
I just did this:
Function CountFields()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strsql As String

Set db = CurrentDb
strsql = "select * from assess"
Set rst = db.OpenRecordset(strsql, dbOpenSnapshot)
Debug.Print rst.Fields.Count
End Function

and it gave me an accurate count. Are you sure that's the sql? Are you sure there's more than one field in the table? Are you sure you're returning a legit recordset? Are you using ADO? (Might be different, I don't know)

Sorry I can't show you what's going on.

Jeremy

==
Jeremy Wallace
AlphaBet City Dataworks
Access Databases for Non-Profit Organizations

Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top