Microsoft KB Archive/210156

= ACC2000: How to Create an Access 2.0 Database with Access 2000 =

Article ID: 210156

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q210156





SUMMARY
This article shows you how to use Data Access Objects (DAO) in Microsoft Access 2000 to create an Access 2.0 database, and how to copy entire tables from an Access 2000 database to the newly created Access 2.0 database. This technique allows you to share data with others who run Access 2.0.



MORE INFORMATION
NOTE: The sample code in this article uses Microsoft Data Access Objects. For this code to run properly, you must reference the Microsoft DAO 3.6 Object Library. To do so, click References on the Tools menu in the Visual Basic Editor, and make sure that the Microsoft DAO 3.6 Object Library check box is selected.

To create an Access 2.0 database and copy tables from the current Access 2000 database, follow these steps:  Start Access and open the sample database Northwind.mdb. In the Database window, click Modules, and then click New.  Type or paste the following procedure: Public Function CreateDB Dim newdb As DAO.DATABASE, mydb As DAO.DATABASE Dim dbname As String Dim tdf As DAO.TableDef

'Set the path and name for the new database. dbname = "C:\Program Files\Microsoft Office" _ & "\Office\Samples\Newdb.mdb"

'Create the new 2.0 database and close newdb. Set newdb = DBEngine.Workspaces(0).CreateDatabase(dbname, _  dbLangGeneral, dbVersion20) newdb.Close

'Export all non-system tables to the version 2.0 database. Set mydb = CurrentDb For Each tdf In mydb.TableDefs If (tdf.Attributes And dbSystemObject) = 0 Then DoCmd.TransferDatabase acExport, "Microsoft Access", _ dbname, acTable, tdf.Name, tdf.Name End If  Next tdf

End Function  To test the function, type the following line in the Immediate window, and then press ENTER:

? CreateDB

Note that the new version 2.0 database is created (in the location that you specified) and that all non-system tables in the current version database are exported to the new version 2.0 database.

NOTE: You can export only tables to an Access 2.0 database; you cannot export other database objects such as forms or reports. If you try to export other objects, you receive the following error message:

Run-time error '7854':

You can't export database objects (except tables) from the current version of Access to previous versions of Access.

In addition, you cannot export tables from databases that have been replicated because these tables have system-defined fields with a data type of ReplicationID. Access 2.0 does not have a ReplicationID data type.

