S
Stuart
I have a table named "Estimate Template" in a closed database
named "Newdb.mdb", which is located in
"C:\Temp\Automate Office".
I create a new database with the following code, which is running
from an Excel VBA module:
Dim appAccess As Access.Application 'dimmed at module level
Sub NewAccessDatabase()
Dim dbs As Object, tdf As Object, fld As Variant
Dim strDB As String
Const DB_Text As Long = 10
Const FldLen As Integer = 40
' Initialize string to database path.
strDB = "C:\Temp\Automate Office\Newdb2.mdb"
' Create new instance of Microsoft Access.
Set appAccess = CreateObject("Access.Application.9")
' Open database in Microsoft Access window.
appAccess.NewCurrentDatabase strDB
' Get Database object variable.
Set dbs = appAccess.CurrentDb
' Do Things
' Append Field and TableDef objects.
tdf.Fields.Append fld
dbs.TableDefs.Append tdf
' Tidy up
Set appAccess = Nothing
End Sub
Q1: How can I copy the table "Estimate Template" from
Newdb.mdb to Newdb2.mdb and rename it (say)
"New Estimate Template".
(the table is pre-formatted with FieldNames, DataType
and FieldWidth etc, ready for spreadsheet data import).
I wish to keep this table as a Template for further use.
Q2: Do not understand the statement:
' Append Field and TableDef objects
Help would be much appreciated, please.
Regards.
named "Newdb.mdb", which is located in
"C:\Temp\Automate Office".
I create a new database with the following code, which is running
from an Excel VBA module:
Dim appAccess As Access.Application 'dimmed at module level
Sub NewAccessDatabase()
Dim dbs As Object, tdf As Object, fld As Variant
Dim strDB As String
Const DB_Text As Long = 10
Const FldLen As Integer = 40
' Initialize string to database path.
strDB = "C:\Temp\Automate Office\Newdb2.mdb"
' Create new instance of Microsoft Access.
Set appAccess = CreateObject("Access.Application.9")
' Open database in Microsoft Access window.
appAccess.NewCurrentDatabase strDB
' Get Database object variable.
Set dbs = appAccess.CurrentDb
' Do Things
' Append Field and TableDef objects.
tdf.Fields.Append fld
dbs.TableDefs.Append tdf
' Tidy up
Set appAccess = Nothing
End Sub
Q1: How can I copy the table "Estimate Template" from
Newdb.mdb to Newdb2.mdb and rename it (say)
"New Estimate Template".
(the table is pre-formatted with FieldNames, DataType
and FieldWidth etc, ready for spreadsheet data import).
I wish to keep this table as a Template for further use.
Q2: Do not understand the statement:
' Append Field and TableDef objects
Help would be much appreciated, please.
Regards.