If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
copy table from closed database
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. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.667 / Virus Database: 429 - Release Date: 23/04/2004 |
Thread Tools | |
Display Modes | |
|
|