C
Conan Kelly
Hello all,
What Libaray do I need to reference in order to use Database and
TableDef data types in VBA as shown in the example below?
Thanks for any help anyone can provide,
Conan Kelly
Sub TableDefX()
Dim dbsNorthwind As Database
Dim tdfNew As TableDef
Dim tdfLoop As TableDef
Dim prpLoop As Property
Set dbsNorthwind = OpenDatabase("Northwind.mdb")
' Create new TableDef object, append Field objects
' to its Fields collection, and append TableDef
' object to the TableDefs collection of the
' Database object.
Set tdfNew = dbsNorthwind.CreateTableDef("NewTableDef")
tdfNew.Fields.Append tdfNew.CreateField("Date", dbDate)
dbsNorthwind.TableDefs.Append tdfNew
With dbsNorthwind
Debug.Print .TableDefs.Count & _
" TableDefs in " & .Name
' Enumerate TableDefs collection.
For Each tdfLoop In .TableDefs
Debug.Print " " & tdfLoop.Name
Next tdfLoop
With tdfNew
Debug.Print "Properties of " & .Name
' Enumerate Properties collection of new
' TableDef object, only printing properties
' with non-empty values.
For Each prpLoop In .Properties
Debug.Print " " & prpLoop.Name & " - " & _
IIf(prpLoop = "", "[empty]", prpLoop)
Next prpLoop
End With
' Delete new TableDef since this is a
' demonstration.
.TableDefs.Delete tdfNew.Name
.Close
End With
End Sub
What Libaray do I need to reference in order to use Database and
TableDef data types in VBA as shown in the example below?
Thanks for any help anyone can provide,
Conan Kelly
Sub TableDefX()
Dim dbsNorthwind As Database
Dim tdfNew As TableDef
Dim tdfLoop As TableDef
Dim prpLoop As Property
Set dbsNorthwind = OpenDatabase("Northwind.mdb")
' Create new TableDef object, append Field objects
' to its Fields collection, and append TableDef
' object to the TableDefs collection of the
' Database object.
Set tdfNew = dbsNorthwind.CreateTableDef("NewTableDef")
tdfNew.Fields.Append tdfNew.CreateField("Date", dbDate)
dbsNorthwind.TableDefs.Append tdfNew
With dbsNorthwind
Debug.Print .TableDefs.Count & _
" TableDefs in " & .Name
' Enumerate TableDefs collection.
For Each tdfLoop In .TableDefs
Debug.Print " " & tdfLoop.Name
Next tdfLoop
With tdfNew
Debug.Print "Properties of " & .Name
' Enumerate Properties collection of new
' TableDef object, only printing properties
' with non-empty values.
For Each prpLoop In .Properties
Debug.Print " " & prpLoop.Name & " - " & _
IIf(prpLoop = "", "[empty]", prpLoop)
Next prpLoop
End With
' Delete new TableDef since this is a
' demonstration.
.TableDefs.Delete tdfNew.Name
.Close
End With
End Sub