Microsoft KB Archive/323203

= ACC2000: Access 2000 Unexpectedly Quits When You Run Code to Open an Object =

Article ID: 323203

Article Last Modified on 6/25/2004

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q323203



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

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).



SYMPTOMS
When you run Microsoft Visual Basic for Applications code to open an object, the database unexpectedly quits. Additionally, you may receive a Dr. Watson message or a different error message that says that the database has performed an illegal function and will be shut down.



CAUSE
The database was created in Microsoft Access 2002, but the database is now in the Access 2000 file format, and you are working in Access 2000.



RESOLUTION
To resolve this issue, refresh the references. You can either refresh the references manually or you can use code to refresh the references.

Refreshing the References Manually

 * 1) Open the database that you are working with.
 * 2) In the Database window, click Modules under Objects.
 * 3) If there is already a module there, open it in Design view. If you do not have any modules in your database yet, click New.
 * 4) In the Visual Basic Editor, click References on the Tools menu.
 * 5) Click to select any reference that is not already selected. Remember the name of the reference, and then click OK.
 * 6) On the Tools menu, click References.
 * 7) Click to clear the reference that you selected in step 5, and then click OK.
 * 8) On the File menu, click Close and Return to Microsoft Access.

Now you can run the code that previously caused Access to quit.

Using Code to Refresh the References
To use code to refresh the references, create the following command button on a form:  In the Database window, click Forms under Objects, and then click New. Click Design View, and then click OK. If the toolbox is not visible, click Toolbox on the View menu. Add a command button to the form. If the Properties dialog box is not visible, click Properties on the View menu. Click the Event tab, click the On Click property, click the down arrow, click [Event Procedure], and then click the Build (...) button.</li>  Type or paste the following code in the subroutine: Dim r As Reference, r1 As Reference Dim s As String

' Look for the first reference in the database other ' than Access and Visual Basic for Applications. For Each r In Application.References If r.Name <> &quot;Access&quot; And r.Name <> &quot;VBA&quot; Then Set r1 = r     Exit For End If Next s = r1.FullPath

' Remove the Reference and add it back. References.Remove r1 References.AddFromFile s

' Call a hidden SysCmd to automatically compile and save all modules. Call SysCmd(504, 16483) </li> On the File menu, click Close and Return to Microsoft Access.</li> Close the form and save the change.</li></ol>

When you want to reset the references, open the form, and then click the command button.

NOTE: If the database is part of a replica set, you must apply this code to the Design Master. Then, run the code when the project component of the database (for example, forms, reports, and modules) is changed. Finally, synchronize the database with the replica.

<div class="status_section">

STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

<div class="moreinformation_section">

MORE INFORMATION
The code that opens the object may be similar to the following: Docmd.Openform &quot; &quot;

-or-

DoCmd.OpenReport &quot; &quot;

Additional query words: inf pra shut down shuts shutdown closes

Keywords: kbbug kbnofix KB323203

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.