Hi guys
How can I know 1.- The number of columns in a table and 2.- The field names
of a query or table.
Thanks
Why?
Several ways, depending upon what you wish to do with the information.
Here is one:
Public Sub CountFields()
Dim db As DAO.Database
Dim tbl As DAO.TableDef
Dim qdf As DAO.QueryDef
Set db = CurrentDb
For Each tbl In db.TableDefs
If Not Left(tbl.Name, 4) = "MSys" Then
Debug.Print tbl.Name,
Debug.Print " Fields count " & tbl.Fields.Count
End If
Next tbl
For Each qdf In db.QueryDefs
If Left(qdf.Name, 1) <> "~" Then
Debug.Print qdf.Name,
Debug.Print " Fields count " & qdf.Fields.Count
End If
Next qdf
End Sub