473,761 Members | 4,082 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to copy existing table structure to create empty temp table?

DoCmd.CopyObjec t copies data, but I only need structure.

I'm trying to clone several tables in my Access 2003 mdb. The goal is to
link to a series of Excel spreadsheets and then run various action queries
against the data in the linked tables (to massage and import it). Since I
can't run action queries against linked Excel tables, I need to create temp
tables that are clones of the required existing tables in the database then
append everything from the linked tables into the temp tables.

For example:

Dim tdf as TableDef
For Each varTbl In Array("tblThis" , "tblThat", etc.)
strTblxls = varTbl & "_xls")
Set tdf = db.CreateTableD ef(strTblxls)
strLink = "Excel 8.0;DATABASE=" & strTblxls
tdf.Connect = strLink
tdf.SourceTable Name = "strTblxls$ "
db.TableDefs.Ap pend tdf
DoCmd.CopyObjec t, varTbl & "_tmp", acTable, varTbl
db.Execute "qryAppendXlsIn toTmp"
[run business logic here to massage and import data]
Next

I have some control over the naming and format of the spreadsheets (which
are an intermediary between a proprietary DB and Access), so that's why they
mirror the existing tables. The problem is DoCmd.CopyObjec t copies all the
data of the existing table, not just the structure. Is there a way to copy
just the structure of an existing table to and empty table with a "_tmp"
suffix? I could write a bunch of DDL queries, but I'm hoping for an easier
way.

Thanks in advance.
Nov 13 '05 #1
1 10960
I think I may have found it...

DoCmd.TransferD atabase

still testing...
Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
6581
by: dev | last post by:
how create a temp table as a copy of a existing table and then update1 field and insert the hole temp table back in the existing table? please any help? if i have 10 fields in 1 record and about 100 records and a field.status=1 in a existing_table and i want to create a temp_table with all the recordse and values of the existing_table and then update the field.status to 2 and insert in 1 query the temp_table in the existing_table
36
4656
by: toedipper | last post by:
Hello, I am designing a table of vehicle types, nothing special, just a list of unique vehicle types such as truck, lorry, bike, motor bike, plane, tractor etc etc For the table design I am proposing a single column table with a field name called vehicle_type and this will contain the vehicle type. Sot it will be
4
15839
by: maricel | last post by:
I have the following base table structure - DDL: CREATE TABLE "ADMINISTRATOR"."T1" ( "C1" INTEGER NOT NULL ) IN "TEST_TS" ; ALTER TABLE "ADMINISTRATOR"."T1" ADD PRIMARY KEY
7
7978
by: Mike Hubbard | last post by:
I have read many many messages about temporary tables and stored procedures. Still, I am struggling with a simple concept. I have a java program which creates a temporary table. I now want to access (read) this table in a stored procedure (written in SQL). This stored procedure is called from the same java program. My question is - how do I "compile" the stored procedure and avoid the error message: DB21034E The command was processed...
5
2380
by: Deano | last post by:
I'm experiencing bloat problems when I restore my backup files. Users can take a look at the reports of any previous backup without having to ensure they have a backup of their current data - this means I have to do a silent backup of the existing database, restore the selected mdb, then restore the silent backup when they are finished viewing the restored data. To the user it appears that they are are just able to see reports relating to...
19
3478
by: davidgordon | last post by:
Hi, I need some pointers/help on how to do the following if it possible: In my access db, I have the following: Tables: Products, Sub-Assembly, Product-Pack Table, Products
4
2278
by: spwpreston | last post by:
Hello, I am new to MySQL. I am trying to load from a text file to a table, and am having problems with the fields in the text file being translated to the correct fields in the TABLE. Right now, I have a tab between each field in the text file, something like: Chicago USA 2,500,000 New York USA 5,000,000
12
2901
by: mantrid | last post by:
Im trying to move a file but am having luck my code is below. The temp and target paths are valid as they echo correctly. but I cant get the copy() function to work, or the rename() function $target_path = $targetdir . basename($uploadedfile); $temp_path = $tempdir. basename($uploadedfile); echo "Target - ".$target_path." Temp - ".$temp_path."<br>";
4
5118
by: Beow | last post by:
Hello, I'm still very new to C++ and have encountered some trouble in understanding how exactly the copy constructor for a stack class (given as an example in the book I've been learning from) using a linked list works. The interface for the classes: template<class T> class Node {
0
9522
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9336
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9948
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9902
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8770
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7327
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5364
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3446
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.