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

table Column count in Access

P: n/a
Hi
I use Access2000 and am trying to count the number of columns in a
table in VBA
Does anyone know if this possible?
thanks
KC

Sep 29 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"KayC" <ka******@yahoo.co.ukwrote in message
<11**********************@b28g2000cwb.googlegroups .com>:
Hi
I use Access2000 and am trying to count the number of columns in a
table in VBA
Does anyone know if this possible?
thanks
KC
If you have opened a recordset based on the table, you can use

msgbox rs.fields.count

Without, you can do something like this with a DAO tabledefs object

msgbox currentdb.tabledefs("tablename").fields.count

Or with ADO, you could do

msgbox _
currentproject.connection.execute("tablename",,adc mdtable).fields.count

--
Roy-Vidar
Sep 29 '06 #2

P: n/a
Hi
Thanks for the help, I was thrown a bit as when I used
redim strTitles(rs.fields.count-1) the value gave me the total rows
instead of total columns
but when I took out the rs.fields.count of the array re dimension the
numbers rec'ed
Strange one
Regards
KC

RoyVidar wrote:
"KayC" <ka******@yahoo.co.ukwrote in message
<11**********************@b28g2000cwb.googlegroups .com>:
Hi
I use Access2000 and am trying to count the number of columns in a
table in VBA
Does anyone know if this possible?
thanks
KC

If you have opened a recordset based on the table, you can use

msgbox rs.fields.count

Without, you can do something like this with a DAO tabledefs object

msgbox currentdb.tabledefs("tablename").fields.count

Or with ADO, you could do

msgbox _
currentproject.connection.execute("tablename",,adc mdtable).fields.count

--
Roy-Vidar
Sep 29 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.