Solved

import ACCESS 2003 scripted objects

Posted on 2011-09-20
5
239 Views
Last Modified: 2012-05-12
Ok, I have a mdoule that exports all the Access 2003 objects and I am happy with that.  I had created a recovery database with teh code to bring all the objects into a blank data - however, to be honest, I can't find it!  Does anyone know teh simple code to bring in all the object that have been exported to text files by the attached code.  This code is fine, I just need the code to bring it into a new, blank database.
On Error GoTo Err_ExportDatabaseObjects
Dim db As DAO.Database
Dim td As DAO.TableDef
Dim d As Document
Dim C As Container
Dim i As Integer
    
    Set db = CurrentDb()
     
    For Each td In db.TableDefs 'Tables
        If Left(td.Name, 4) <> "MSys" Then
           DoCmd.TransferText acExportDelim, , td.Name, sExportLocation & "Table_" & td.Name & ".txt", True
       End If
   Next td
    
    Set C = db.Containers("Forms")
    For Each d In C.Documents
        Application.SaveAsText acForm, d.Name, sExportLocation & "Form_" & d.Name & ".txt"
    Next d
    
    Set C = db.Containers("Reports")
    For Each d In C.Documents
        Application.SaveAsText acReport, d.Name, sExportLocation & "Report_" & d.Name & ".txt"
    Next d
    
    Set C = db.Containers("Scripts")
    For Each d In C.Documents
        Application.SaveAsText acMacro, d.Name, sExportLocation & "Macro_" & d.Name & ".txt"
    Next d
    
    Set C = db.Containers("Modules")
    For Each d In C.Documents
        Application.SaveAsText acModule, d.Name, sExportLocation & "Module_" & d.Name & ".txt"
    Next d
    
    For i = 0 To db.QueryDefs.Count - 1
        Application.SaveAsText acQuery, db.QueryDefs(i).Name, sExportLocation & "Query_" & db.QueryDefs(i).Name & ".txt"
    Next i
    
    Set db = Nothing
    Set C = Nothing

Open in new window

0
Comment
Question by:ssmith94015
  • 3
  • 2
5 Comments
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
Comment Utility
use, something like this

Application.LoadFromText acForm, "XMain", "E:\main.txt"
0
 

Author Comment

by:ssmith94015
Comment Utility
Cap, I thought it would be you!  I think to answered this question many years ago, I just can't find that question/answer.  Let me try and I will be right back.
0
 

Author Closing Comment

by:ssmith94015
Comment Utility
Yes, this was it.  I am going to assume that for each object type, module, report, form, query, I would simply replace the acForm with the correct constant.

Sandra
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
you can iterate all .txt file in the folder with

dim txtPath,txtFile
txtpath="c:\myfolder\"

txtfile=dir(txtPath & "*.txt")

while txtFile <>""
   select case left(txtfile,instr(txtFile,"_")-1)
         case "Form"

         case "Table"

         'etc...
   end select
0
 

Author Comment

by:ssmith94015
Comment Utility
Thanks, that will work even better.  
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The System Center Operations Manager 2012, known as SCOM, is a part of the Microsoft system center product that provides the user with infrastructure monitoring and application performance monitoring. SCOM monitors:   Windows or UNIX/LinuxNetwo…
This collection of functions covers all the normal rounding methods of just about any numeric value.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now