473,769 Members | 2,078 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Copying database structure without the data

1 New Member
I need to make a new database at the beginning of every year but have forgotten how to do this quickly and efficiently.

I have a database with about 10 tables, 10 forms related to the 10 tables and likewise 10 reports. The same objects in my 2006 database, 2005, 2004 etc.
I need to make a new database for 2007 using the identical structure.

There is some quick way of copying the 2006 database so that all the tables, forms , reports i.e. all the objects come across but empty, without the data.
Before I learnt how to do this, I used to create a new blank database and copy each table individually by copy and pasting structure only. This is slow and timeconsuming. There is a better way.
Help will be most gratefully accepted.
Dec 29 '06 #1
2 5383
nico5038
3,080 Recognized Expert Specialist
You can use for tables the TransferDatabas e command that has an option "structure only":

DoCmd.TransferD atabase acExport, "Microsoft Access", strDatabase, acTable, "tblTest", "tblTest", True

For forms/queries/etc you can use the CopyObject like:
DoCmd.CopyObjec t strDatabase, , acForm, "frmMain"

Nic;o)
Dec 29 '06 #2
NeoPa
32,573 Recognized Expert Moderator MVP
I've had to do this a couple of times now and what I do (mainly because remembering all the details is so unreliable) is I copy the whole damn thing then I write some very short code (I'll include it below) to clear out all the data from the tables. When that is all done I run a 'Compact and Repair' leaving me with all the items I need.
Expand|Select|Wrap|Line Numbers
  1. 'ClearNativeTables clears tables that are native to this database
  2. Public Sub ClearNativeTables()
  3.     Dim tblThis As TableDef
  4.  
  5.     Call DoCmd.SetWarnings(False)
  6.     For Each tblThis In CurrentDb.TableDefs
  7.         With tblThis
  8.             If .Connect = "" And .Attributes = 0 Then _
  9.                 Call DoCmd.RunSQL("DELETE FROM [" & .Name & "]")
  10.         End With
  11.     Next tblThis
  12.     Call DoCmd.SetWarnings(True)
  13. End Sub
Dec 31 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2320
by: kjphipps_377 | last post by:
Hi all! I have an application that needs to copy the database structure from one database to another without using the "Generate SQL Script" function in Enterprise Manager. I'd like to do this from within a stored procedure. Can someone recommend the best approach for this? I've seen references to using SQL-DMO from a stored procedure using the sp_OA* procs in other postings to this group but was wondering if there was an easier way?...
1
8688
by: Jani Tamminen | last post by:
I want to copy data from our production database to the development database. I want to move only the data. I do not need the table structure, constrains or anything else. I think I can use the db2move command to export out all the data like the following: db2move dbname export -tc schema1
4
1685
by: nick_faye | last post by:
hi guys, hope somebody can assist me. i have two ms access database. i have to copy the entries in database1 to my database2. however, i have to copy entries from database1 that does not exist yet in the entries in my database2. i am using INSERT INTO table_in_database2 SELECT fields_from_table_in_database1 FROM table_in_database1 IN directory_of_database1. i was trying to put a WHERE command but i always get an error. please help.
8
1920
by: brian kaufmann | last post by:
Hi, I'm new to Access and this may be a basic question but I would appreciate it if you could let me know how to do this: I've created an Access table and would like to insert a column with the field name "name" and to put the same word "unknown" down all the rows of the column. How could this be done both in the design mode and in sql code?
1
2303
by: Eric Sadoyama | last post by:
I have a database documentation question, but I am not even sure how to phrase it properly so I don't know where to start looking for answers. We are developing a database that is based on several different data standards and schema. I'm finding it confusing to keep it all straight. What's this field for? Which standards document is it based on? What are the permitted values? Which business rule governs it? In theory, we do have all...
8
2763
by: situ | last post by:
Hello all, i have Database1 and database2, is it possible to make database connection to database2 by running stored procedure on database1. Thanks and Regards Situ
221
367724
Atli
by: Atli | last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t. In situations where your PHP application needs to store entire files, the preferred method is to save the file onto the server’s file-system, and store the physical location of the file in your database. This is generally considered to be the easiest and fastest way to store files. ...
9
2336
by: Peter Duniho | last post by:
Is there a straightfoward API in .NET that allows for inspection of a database? That is, to look at the structure of the database, without knowing anything in advance about it? For example, retrieving a list of tables in the database. Doing a little browsing in MSDN, I see that the abstract representation of a database appears to be the DataSet class. I also see that I can use "data adapter" classes (e.g. OdbcDataAdapter) to connect a...
2
7207
by: O.B. | last post by:
When using Marshal to copy data from a byte array to the structure below, only the first byte of the "other" array is getting copied from the original byte array. What do I need to specify to get Marshal.PtrToStructure to copy the all the data into the "other" array? unsafe public struct DeadReckoning {
0
9579
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
9422
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
10208
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10038
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...
0
9857
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8867
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...
0
5444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3558
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2812
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.