Solved

Converting a Access 2000 DB to a 97DB in VBA

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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 …

758 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

20 Experts available now in Live!

Get 1:1 Help Now