Solved

Converting a Access 2000 DB to a 97DB in VBA

Posted on 2002-07-19
5
747 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

808 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