A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

copy table from closed database



 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old April 25th, 2004, 09:24 AM
Stuart
external usenet poster
 
Posts: n/a
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:19 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.