473,395 Members | 1,484 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Copying database structure without the data

1
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 5326
nico5038
3,080 Expert 2GB
You can use for tables the TransferDatabase command that has an option "structure only":

DoCmd.TransferDatabase acExport, "Microsoft Access", strDatabase, acTable, "tblTest", "tblTest", True

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

Nic;o)
Dec 29 '06 #2
NeoPa
32,556 Expert Mod 16PB
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
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...
1
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...
4
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...
8
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...
1
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...
8
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
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...
9
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,...
2
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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...

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.