[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

09/11/2009 at 07:28AM PDT, ID: 24724655
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.0

VBA code to copy table structure and data from one access database to another

Asked by sxxgupta in Access Coding/Macros, Microsoft Access Database

Right now I have a database that contains liked SQL tables.  If I want to analyze data "offline", I simply just cannot copy the database as another .mdb file because the tables are copied as linked SQL tables.  Could someone please help me in developing VBA code that will copy the table structure and data to another .mdb file?  The tables being copied should have the same name.  Right now I have some code bits for exporting queries, macros, etc to an offline database defined by the variable qaPath (see code below).  I want to follow the same logic of copying the table structure and data of these linked SQL tables that I can insert into the code below.  Right now I am using a macro (called 'z copy tables') to peform this task, where essentially I am using artificially created queries to output the data of these linked tables and then copying these queries outputs as data inputs to my offline tables.  I think this is extremely inefficient especially if new linked SQL tables are created that I have to keep track of it.  I believe VBA is the way to go.  I have attached an example of one line of the macro below:

Transfer Type: Export
Database Type: Microsoft Access
Database Name: C:\Documents and Settings\sanjayg\Desktop\qa.mdb
Object Type: Table
Source: copy Test  ------------------------The name of the table is Test and I have created query 'copy Test' to output table Test data
Destination: Test --------------------------The new name of the table is the same as the name of the linked table
Structure Only: No

I would have to do this about 100 times because there are about that many tables.  This means I would have to create 100 queries and then fill in 100 line items in the macro to copy the table structure and data and export the table object, its structure, and data to "qaPath".

Please help.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
Sub exportdbobjects1()
Dim db As DAO.Database, qdf As DAO.QueryDef, qaPath As String, j As Integer, rpt, mdl, frm, mac
On Error GoTo ProcErr
qaPath = "C:\Documents and Settings\sanjayg\Desktop\qa.mdb"
Set db = CurrentDb
 
 For Each qdf In db.QueryDefs
   If Left(qdf.Name, 1) <> "~" Then
       DoCmd.TransferDatabase acExport, "Microsoft Access", qaPath, acQuery, qdf.Name, qdf.Name
   End If
Next
 
For j = 0 To db.Containers("Reports").Documents.Count - 1
    rpt = db.Containers("Reports").Documents(j).Name
    DoCmd.TransferDatabase acExport, "Microsoft Access", qaPath, acReport, rpt, rpt
Next
 
For j = 0 To db.Containers("Modules").Documents.Count - 1
    mdl = db.Containers("Modules").Documents(j).Name
    DoCmd.TransferDatabase acExport, "Microsoft Access", qaPath, acModule, mdl, mdl
Next
 
For j = 0 To db.Containers("Scripts").Documents.Count - 1
    mac = db.Containers("Scripts").Documents(j).Name
    DoCmd.TransferDatabase acExport, "Microsoft Access", qaPath, acMacro, mac, mac
Next
 
For j = 0 To db.Containers("Forms").Documents.Count - 1
    frm = db.Containers("Forms").Documents(j).Name
    DoCmd.TransferDatabase acExport, "Microsoft Access", qaPath, acForm, frm, frm
Next
 
DoCmd.RunMacro "z copy tables"
 
MsgBox "Finished Exporting Objects."
 
ProcExit:
   On Error Resume Next
   Exit Sub
ProcErr:
   MsgBox Err.Description
   Resume ProcExit
End Sub
[+][-]09/11/09 08:33 AM, ID: 25310584

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/11/09 08:37 AM, ID: 25310609

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/11/09 08:45 AM, ID: 25310689

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Access Coding/Macros, Microsoft Access Database
Sign Up Now!
Solution Provided By: capricorn1
Participating Experts: 1
Solution Grade: A
 
 
[+][-]09/11/09 08:59 AM, ID: 25310822

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/11/09 10:23 AM, ID: 25311605

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/11/09 10:26 AM, ID: 25311642

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/11/09 10:30 AM, ID: 25311671

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/11/09 11:40 AM, ID: 25312288

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/11/09 11:54 AM, ID: 25312420

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/11/09 12:01 PM, ID: 25312485

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/11/09 12:01 PM, ID: 25312487

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/11/09 12:04 PM, ID: 25312509

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/11/09 12:05 PM, ID: 25312514

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/11/09 12:06 PM, ID: 25312518

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/11/09 12:08 PM, ID: 25312536

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/11/09 12:09 PM, ID: 25312554

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/11/09 12:10 PM, ID: 25312568

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/11/09 12:10 PM, ID: 25312570

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/11/09 12:13 PM, ID: 25312591

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/11/09 12:14 PM, ID: 25312599

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/11/09 12:21 PM, ID: 25312652

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-91 - Hierarchy / EE_QW_3_20080625