Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to SQL 2 Seminar Lessons    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Make table on another database
Sami Shamma 
             
3 years ago
Hi

I would like to create back up tables before I delete two of my tables on a daily basis. Can I create these back up tables as in this video, but have them created on a different database file than the one I am in?
Many thanks

Dr. Sami Shamma
Kevin Yip  @Reply  
     
3 years ago
To control another database you need to do it entirely in VBA.  This is how you open another .accdb file and add a table to it:

    Dim db As DAO.Database
    Set db = DBEngine.Workspaces(0).OpenDatabase("C:\My Documents\MyDB.accdb")
    db.Execute "CREATE TABLE MyNewTable (ID AUTOINCREMENT PRIMARY KEY, FIELD1 TEXT(255), FIELD2 SMALLINT, FIELD3 INT, FIELD4 DATE);"
    db.Close

This will create a table named "MyNewTable" in the specified database, with an autonumber primary key field, a short text field, an integer field, a long integer field, and a date/time field.

This method is often used in environments outside of Access, such as Word VBA or Excel VBA.

"CREATE TABLE" is a special query type that creates a table from scratch.  Not to be confused with a "make table" query.  Notice the differences in nomenclature: autonumber is called AUTOINCREMENT, integer is SMALLINT, and so on.
Sami Shamma OP  @Reply  
             
3 years ago
Many thanks Kevin.
Appreciate your help.
Sami Shamma OP  @Reply  
             
3 years ago
Hi Kevin
As it happens, the table I want to back up is the one with the most fields (53).
is it possible to create a time stamped backup on the other Database of this one table without having to define all the fields as you have shown me above?

Again thanks for your help.
Kevin Yip  @Reply  
     
3 years ago
Another way to transfer a table is to export it.  You can do it manually by going to External Tables -> Access, and follow the wizard.  To do it automatically with VBA, you run this in the database you want to transfer from:

     DoCmd.TransferDatabase acExport, "Microsoft Access", "C:\My Documents\MyDestinationDB.accdb", acTable, "MyOriginalTableName", "MyDestinationTableName", False

I believe Richard has a video on this, but I don't know which one.  The "False" at the end is important; that means both the table's structure and data will be exported; "True" will only export the structure.

Regarding "time stamp", maybe you can put it in the name of the backup table.  E.g. "MyDestinationTable - backed up on 9-16-23".
Sami Shamma OP  @Reply  
             
3 years ago
Kevin

This is exactly what I needed.
It worked like a charm.

Cant thank you enough


This thread is now CLOSED. If you wish to comment, start a NEW discussion in SQL 2 Seminar Lessons.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/31/2026 12:24:14 PM. PLT: 0s