Can anyone please tell how to count the number of COLUMNS in Access database by using Visual Basic programming? Thank you.
Printable View
Can anyone please tell how to count the number of COLUMNS in Access database by using Visual Basic programming? Thank you.
Try this
Change the names of mdb and table names.
Dim db As Database
Dim rs As Recordset
Set db = opendatabase("C:\Program Files\MSOFFICE\access\Samples\northwind.mdb")
Set rs = db.OpenRecordset("select * from customers", dbOpenSnapshot)
MsgBox CStr(rs.Fields.Count)
rs.Close
db.Close
you can inspect the TableDefs collection of the database object in DAO and query the fields.count property.