Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

import ACCESS 2003 scripted objects

Posted on 2011-09-20
5
Medium Priority
?
268 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 36567706
use, something like this

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

Author Comment

by:ssmith94015
ID: 36567736
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
ID: 36567769
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 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 36567774
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
ID: 36567793
Thanks, that will work even better.  
0

Featured Post

Does Your Cloud Backup Use Blockchain Technology?

Blockchain technology has already revolutionized finance thanks to Bitcoin. Now it's disrupting other areas, including the realm of data protection. Learn how blockchain is now being used to authenticate backup files and keep them safe from hackers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

730 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