p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

access thread: Creating Access db on the fly


Message #1 by "Ajay Jain" <ajain@i...> on Mon, 3 Jun 2002 16:04:04 -0400
Hello All:

I have to create a partial backup of MS Access database on the fly. For eg.
I have 10 tables in my current database. Now, I need to create a new
database with only 5 tables present in it using a utility.

I am wondering if I can fire "Create table" statements from MS Access. Or is
there any other way out to this problem. I have to retain the complete table
structure with data and integrity constraints.

Any help is be highly appreciated!

Thank You

Ajay Jain

Message #2 by "Randy Cornish" <rlcornish@c...> on Tue, 4 Jun 2002 00:44:54
There are several ways to do this:

  * As I just finished responding in a different posting, you can use 
DAO's Object model.  MyDB.Tables.Add .....  It is quite a bit to show how 
to do this in a posting.  I would suggest a book by Ken Getz or Helen 
Feddema to pursue this.  Is very fast.
  *  You could read up on the CopyObject() or TransferDatabase() Access 
commands and see if these serve your purposes.
  *  A really quick way to do this is to create a "template" (empty) of 
what the backup database looks like (without the data).  Then, use 
FileCopy (in a code module) to copy your template to the target backup 
file.  Example:
  strTemplate = "c:\MyApp\bkptemp.tem"  '* an Access MDB
  strTarget = "c:\MyApp\Backup06032002.mdb"
  VBA.FileCopy  strTemplate, strTarget

  Then, just use Update queries to move the data from your production 
  MDB to the backup.  Clean, neat, minimal coding.

R  

> Hello All:

I have to create a partial backup of MS Access database on the fly. For 
eg.
I have 10 tables in my current database. Now, I need to create a new
database with only 5 tables present in it using a utility.

I am wondering if I can fire "Create table" statements from MS Access. Or 
is
there any other way out to this problem. I have to retain the complete 
table
structure with data and integrity constraints.

Any help is be highly appreciated!

Thank You

Ajay Jain

Message #3 by "Amy Wyatt" <amyw@c...> on Tue, 4 Jun 2002 13:51:45
Depending on how often, how much data and how complicated the table 
structures you could get by with 'Make Table' queries that duplicate the 
tables and the data even into another database. This however would 
probably slow things down if we are talking lots of data and doing this 
often. In that case, writing code to build the tables might be better.

Amy

> Hello All:

I have to create a partial backup of MS Access database on the fly. For eg.
I have 10 tables in my current database. Now, I need to create a new
database with only 5 tables present in it using a utility.

I am wondering if I can fire "Create table" statements from MS Access. Or 
is
there any other way out to this problem. I have to retain the complete 
table
structure with data and integrity constraints.

Any help is be highly appreciated!

Thank You

Ajay Jain


  Return to Index