Switchboard causes a compile error after you convert a Access 2000 database to Access 97 (262847)



The information in this article applies to:

  • Microsoft Access 97

This article was previously published under Q262847
Moderate: Requires basic macro, coding, and interoperability skills.

SYMPTOMS

When you open a Switchboard form in a Microsoft Access 97 database that was converted from Microsoft Access 2000, you receive the following error message:
Compile error: Method or data member not found.
Microsoft Access then highlights the following line of code in the Switchboard form.
Set con = Application.CurrentProject.Connection
				

CAUSE

The Visual Basic for Applications code in the Switchboard form refers to the Application.CurrentProject.Connection property, which is not available in Microsoft Access 97.

RESOLUTION

There are two possible solutions to this problem.

Solution 1: Re-create the Switchboard form in Microsoft Access 97

The Switchboard Manager creates and modifies two main objects: the Switchboard Items table, and the Switchboard form. The Switchboard Items table contains all the information that defines the items on the Switchboard, and this information has not significantly changed since Microsoft Access 97. Therefore, you can use the Switchboard Manager in Microsoft Access 97 to re-create the Switchboard form by using the Switchboard Items table from Microsoft Access 2000.

NOTE: The following example assumes that you have already converted a database with a Switchboard form from Access 2000 to Access 97. If you have questions about how to do this, follow steps 1 through 17 in the "Steps to Reproduce the Behavior" section later in this article.
  1. After opening the database in Microsoft Access 97, click the Forms tab. Right-click the Switchboard form, and then click Rename. Rename the form to Switchboard 2000.
  2. Click the Tables tab. Right-click the Switchboard Items table, and then click Rename. Rename the table to Switchboard Items 2000.
  3. On the Tools menu, point to Add-ins, and then click Switchboard Manager.
  4. Click Yes in the dialog box that prompts you to create a new switchboard.
  5. Click Close to close the Switchboard Manager.
  6. Click the Tables tab. Rename the Switchboard Items table to Switchboard Items 97.
  7. Rename the Switchboard Items 2000 table to Switchboard Items.
  8. Click the Forms tab, and then open the Switchboard form. It should open successfully, and you should be able to use it without errors.
  9. Close the Switchboard form.
After you verify that the Switchboard form works correctly, you can permanently delete the Switchboard Items 97 table and the Switchboard 2000 form.

Solution 2: Replace the ADO code in the Switchboard form with DAO

NOTE: The following example assumes that you have already created an Access 2000 database with a Switchboard form. If you have questions about how to do this, follow steps 1 through 17 in the "Steps to Reproduce the Behavior" section later in this article.
  1. Open the Switchboard form in Design View.
  2. On the View menu, click Code to open the form's module in the Visual Basic Editor.
  3. Locate the FillOptions() procedure, and make the following modifications to it.

    Replace the following line of code
    Set con = Application.CurrentProject.Connection
    with:
    Set con = CurrentDb
    Replace the following line of code
    rs.Open stSql, con, 1   ' 1 = adOpenKeyset
    with:
    Set rs = con.OpenRecordset(stSql)
    Remove the following line of code:
    Set rs = CreateObject("ADODB.Recordset")
    Locate the HandleButtonClick() procedure, and make the same modifications that you just made to the FillOptions() procedure.
  4. On the Debug menu, click Compile ProjectName.
  5. Close and save the Switchboard form.
  6. Convert the database to Access 97. For additional information on how to do this, follow steps 15 through 17 in the "Steps to Reproduce the Behavior" section later in this article.
The Switchboard form should now open successfully in Microsoft Access 97.

MORE INFORMATION

The code in the Switchboard form was updated in Microsoft Access 2000 to use ActiveX Data Objects (ADO). In order to obtain an ADO connection to the currently open database, the code in the Switchboard form refers to the Application.CurrentProject.Connection property. This property is new to Microsoft Access 2000 and is not available in Microsoft Access 97.

Steps to Reproduce the Behavior

  1. Start Microsoft Access 2000.
  2. Open the sample database Northwind.mdb.
  3. On the Tools menu, point to Database Utilities, and then click Switchboard Manager.
  4. Click Yes in the dialog box that prompts you to create a new switchboard.
  5. In the Switchboard Manager dialog box, click Edit.
  6. In the Edit Switchboard Page dialog box, click New.
  7. In the Edit Switchboard Item dialog box, type the following:

    Text:Edit Customers
    Command:Open Form in Edit Mode
    Switchboard:Customers
  8. In the Edit Switchboard Item dialog box, click OK.
  9. In the Edit Switchboard Page dialog box, click Close.
  10. In the Switchboard Manager, click Close.
  11. In the Database window, click Forms under Objects.
  12. Open the Switchboard form in Form view.
  13. Click the Edit Customers button to verify that the Switchboard form will open the Customers form.
  14. Close the Customers form and the Switchboard form.
  15. On the Tools menu, point to Database Utilities, point to Convert Database, and then click To Prior Access Database Version.
  16. Type Northwind97, and then click Save.
  17. Open Northwind97.mdb in Microsoft Access 97. Click OK to the message that the Visual Basic for Applications code has been converted.
  18. After the conversion process is finished, open the Switchboard form. Note that you receive the error:
    Compile error: Method or data member not found.
    Microsoft Access then highlights the following line of code in the Switchboard form.
    Set con = Application.CurrentProject.Connection
    						

Modification Type:MinorLast Reviewed:11/18/2004
Keywords:kberrmsg kbprb KB262847