Return Count of Columns in an Access Table via VBA

  • Thread starter Thread starter Amcbdc1
  • Start date Start date
A

Amcbdc1

I need to return the number of columns in a table using VBA code. That way I
can tell if i need to add more columns to hold the data that will be inserted
into the database via code.
 
I need to return the number of columns in a table using VBA code. That way I
can tell if i need to add more columns to hold the data that will be inserted
into the database via code.

Not in any rationally designed normalized database, you won't!!!

That said, CurrentDb.Tabledefs("MyTableName").Fields.Count will return the
number of fields.
 
Not in any rationally designed normalized database, you won't!!!

Hi John,

That's true. But there's a case for programmatically adding columns
to a work table (flattening the data crosstab style) before exporting
it to Excel or similar. Very handy.

But that doesn't seem to be the situation here, so your advice stands.
:)

Armen Stein
Microsoft Access MVP
www.JStreetTech.com
 
Back
Top