I suppose a more standard way might be helpful too (if you want to manage it in code).
The following code entered in as a single line will run in the Immediate Pane (Ctrl-G from the VBA Editor).
- For Each tbl in CurrentDb.TableDefs : ?tbl.Name : Next tbl
It produces a list of all the tables in your database.
Strangely, the following code worked to produce a list of fieldnames for each field in a table. Any use of object variables though, produced errors. No idea why I'm afraid.
- Public Sub ShowFields(strTable As String)
-
Dim intIx As Integer
-
-
For intIx = 0 To CurrentDb.TableDefs(strTable).Fields.Count - 1
-
Debug.Print CurrentDb.TableDefs(strTable).Fields(intIx).Name
-
Next intIx
-
End Sub
The following, for instance, should be equivalent and work exactly the same. It didn't for me :(
- Public Sub ShowFields(strTable As String)
-
Dim intIx As Integer
-
-
With CurrentDb.TableDefs(strTable)
-
For intIx = 0 To .Fields.Count - 1
-
Debug.Print .Fields(intIx).Name
-
Next intIx
-
End With
-
End Sub