ACC: How to Create a Version 2.0 Database Using Access 95/97

Last reviewed: August 28, 1997
Article ID: Q141886
The information in this article applies to:
  • Microsoft Access 7.0, 97

SUMMARY

Moderate: Requires basic macro, coding, and interoperability skills.

This article demonstrates how you can use data access objects (DAO) to create a Microsoft Access 2.0 database and to copy entire tables from a Microsoft Access 7.0 or 97 database. This technique enables you to share data with others who run Microsoft Access 2.0.

This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to your version of the "Building Applications with Microsoft Access" manual.

MORE INFORMATION

To create a Microsoft Access 2.0 database and copy tables from the current Microsoft Access 7.0 or 97 database, follow these steps:

  1. Create a new module.

  2. Type the following procedure:

          Public Function CreateDB()
    
             Dim newdb As DATABASE, mydb As DATABASE
             Dim dbname As String
             Dim tdf As TableDef
    
             'Set the path and name for the new database.
             dbname = "c:\msoffice\access\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
    
    

  3. To test the function, type the following line in the Debug window, and then press ENTER.

          ? CreateDB()
    

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

    NOTE: You can export only tables to a Microsoft 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:

          Run-time error '7854':
          You can't export database objects (except tables) from the
          current version of Microsoft Access to previous versions of
          Microsoft Access.
    

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

REFERENCES

For more information about creating databases using DAO, search for "CreateDatabase," and then "CreateDatabase method" using the Microsoft Access 97 Help Index.

For more information about the Attributes property and the dbSystemObject constant, search for "Attributes," and then "Attributes property" using the Microsoft Access 97 Help Index.

Keywords          : kbprg PgmHowTo MdlDao
Version           : 7.0 97
Platform          : WINDOWS
Hardware          : x86
Issue type        : kbhowto


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: August 28, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.