VBA to import 344 objects from 97 to 2003

  • Thread starter Programmer - wannaB
  • Start date
P

Programmer - wannaB

Rs.Fields("Name").Value = "Econ" and that is the first FORM to be imported
Doc = nothing

could this have anything to do with DIM Doc As DAO.Document, could it be a
string, (please tell me if I've made a stupid statement , and why)
=================================
 
P

Programmer - wannaB

I've got that FIXED... however now it keeps copying the Econ Form.
I'm not sure where or how to rtell it to step through, but here's my best
guess

Here the Mod with my guess in <>
Public Sub ObjectsTbl()
' Code Modified to Import into access 2003 from Access '97
Dim Db As DAO.Database
Dim Cont As DAO.Container
Dim Doc As DAO.Document
Dim Rs As DAO.Recordset
Dim ObjType As thObjType
Dim FromDb As DAO.Database

Set FromDb = Access.DBEngine.OpenDatabase("D:\D:\Dev\StageingDb.mdb")
Set Db = Access.CurrentDb()
Set Rs = FromDb.OpenRecordset("SELECT NAME, TYPE FROM USysObjects",
DAO.dbOpenSnapshot)
While Not Rs.EOF
Select Case Rs.Fields("Type").Value
Case thObjType.thTable
Set Cont = FromDb.Containers("Tables")
Set Doc = Cont.Documents(Rs.Fields("Name").Value)
ObjType = GetObjType(Cont.Name)
Case thObjType.thQuery ' Special Case !!!
Set Cont = FromDb.Containers("Tables")
Set Doc = Cont.Documents(Rs.Fields("Name").Value)
ObjType = GetObjType("Queries")
Case thObjType.thMacro
Set Cont = FromDb.Containers("Scripts")
Set Doc = Cont.Documents(Rs.Fields("Name").Value)
ObjType = GetObjType(Cont.Name)
Case thObjType.thForm
Set Cont = FromDb.Containers("Forms")
Set Doc = Cont.Documents(Rs.Fields("Name").Value)
ObjType = GetObjType(Cont.Name)
Case thObjType.thReport
Set Cont = FromDb.Containers("Reports")
Set Doc = Cont.Documents(Rs.Fields("Name").Value)
ObjType = GetObjType(Cont.Name)
Case thObjType.thModule
Set Cont = FromDb.Containers("Modules")
Set Doc = Cont.Documents(Rs.Fields("Name").Value)
ObjType = GetObjType(Cont.Name)
End Select
Access.Application.DoCmd.TransferDatabase acImport, "Microsoft Access",
FromDb.Name, ObjType, Doc.Name, Doc.Name
<next RS.Fields("Name")>
Wend
Rs.Close: Set Rs = Nothing
FromDb.Close: Set FromDb = Nothing
Set Db = Nothing
End Sub


OH FYI - the fix for the last error - I had somehow removed Cont.Documents(
from in front of RS.Fields("Name").Value - and it was only missing from the
Forms
section.
======================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top