Solved

Converting a Access 2000 DB to a 97DB in VBA

Posted on 2002-07-19
5
749 Views
Last Modified: 2007-11-27
I am trying to write this code to create a copy of the
main 4 tables in my database into a different Access
database.

I am using Access 2000 and need to convert a copy of the
backup database to 97 for a co-worker.

The code below works fine until the line:

DoCmd.RunCommand acCmdConvertDatabase

I get a runtime error of 2046 and a message that says  
   
The comaand or action 'Convert DataBase' isn't    
availble now


I even created a database with an sub that had
DoCmd.RunCommand acCmdConvertDatabase as its only line and
the message was the same.

Any ideas to get this to work or another way to do it.


Thanks

Charley

=======Code===
Sub NewAccessDatabase()
Dim appAccess As Access.Application
Dim dbsCurrent As Database, dbsContacts As Database
Set dbsCurrent = CurrentDb

    Dim dbs As Object, tdf As Object, fld As Variant
    Dim strDB As String
    Const DB_Text As Long = 10
    Const FldLen As Integer = 40

    ' Initialize string to database path.
    strDB = "C:\Newdbcwd7.mdb"
    ' Create new instance of Microsoft Access.
    Set appAccess = _
        CreateObject("Access.Application.9")
    ' Open database in Microsoft Access window.
    appAccess.NewCurrentDatabase strDB
    ' Get Database object variable.
      Set appAccess = Nothing
 Set dbs = CurrentDb()
Set dbsContacts = DBEngine.Workspaces(0).OpenDatabase
(strDB)
    ' Create new table.
    DoCmd.CopyObject strDB, , acTable, "tblCuidOld"
   
    DoCmd.RunCommand acCmdConvertDatabase
.

0
Comment
Question by:charleyd
5 Comments
 
LVL 9

Expert Comment

by:perove
ID: 7164976
If it is just the tables, you could export them to XL (or something), then start access97  and import them.

I havent done converting backwards, but to ubgrade say from 2000->2002 it is important to do a compile/save all modules AND a compact before starting the operation..



perove
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 7165296
why don't you simply use the Access 2000 capability to Convert to the earlier verion:

Under Tools/Database Utilities/Convert Database   this will convert the 2000 Database back to a Access 97.

Make a Copy, and then convert the copy back to Access 97.

Arthur Wood
0
 

Author Comment

by:charleyd
ID: 7165376
perove

I am no longer running Access 97.

Authur

I am trying do the conversion in VBA. I am presently using the menus.

Thanks

0
 
LVL 28

Accepted Solution

by:
TextReport earned 200 total points
ID: 7165494
All you need to do is the following, you will need a reference to MS DAO. dbVersion30 is for Access 95 and 97, Jet 3.0 and 3.5.


Sub EportTo97()
Dim db As Database

Const conNewFileName = "c:\My97.mdb"
    If Dir(conNewFileName) <> "" Then Kill conNewFileName
    Set db = DBEngine.CreateDatabase(conNewFileName, dbLangGeneral, dbVersion30)
    DoCmd.TransferDatabase acExport, "Microsoft Access", conNewFileName, acTable, "Table01", "Table01", False, False

End Sub

Cheers, Andrew
0
 

Author Comment

by:charleyd
ID: 7165738
Andrew

It works perfectly

Thanks

Charley

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

679 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