Microsoft KB Archive/295242

= ACC2002: Microsoft Access Quits When You Programmatically Switch Views on Open Tables or Queries =

Article ID: 295242

Article Last Modified on 9/25/2003

-

APPLIES TO


 * Microsoft Access 2002 Standard Edition

-



This article was previously published under Q295242



Novice: Requires knowledge of the user interface on single-user computers.

This article applies only to a Microsoft Access database (.mdb).



SYMPTOMS
When you use Visual Basic for Applications (VBA) code to switch between views on open tables or queries, you may receive the following error message, and then Microsoft Access quits:

Microsoft Access has encountered a problem and needs to close. We are sorry for the inconvenience.

When you view the details in the error report, the report states that an error has occurred in Msaccess.exe.



CAUSE
You receive the error message if the table or query is currently open.



RESOLUTION
If you must change the view of the table or query, you must modify your code to first close the open table or query, and then reopen the table or query for the view that you want.

For the example in the &quot;Steps to Reproduce the Behavior&quot; section later in this article, you can change the code and correct the behavior as follows:   For the Customer Table in Print Preview command button, make the following code changes: DoCmd.Close acTable, &quot;customers&quot; DoCmd.OpenTable &quot;Customers&quot;, acViewPreview   For the Switch Customer Table to Design View command button, make the following code changes: DoCmd.Close acTable, &quot;customers&quot; DoCmd.OpenTable &quot;Customers&quot;, acViewDesign 



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



Steps to Reproduce the Behavior
 In the Northwind sample database, create a new form.  Add a command button to the form, and then set the following properties: <pre class="fixed_text">  Command button --  Name: Command1 Caption: Customer Table in Print Preview OnClick: [Event Procedure] </li>  Set the OnClick property of the Command1 command button to the following event procedure: DoCmd.OpenTable &quot;Customers&quot;, acViewPreview </li>  Add another command button to the form, and then set following properties: <pre class="fixed_text">  Command button --  Name: Command2 Caption: Switch Customer Table to Design View OnClick: [Event Procedure] </li>  Set the OnClick property of the Command2 command button to the following event procedure: DoCmd.OpenTable &quot;Customers&quot;, acViewDesign </li> Save the form as Form1 .</li> Open the Form1 form, and then click the Customer Table in Print Preview button.</li> Switch back to the form without closing the preview of the Customers table, and then click the Switch Customer Table to Design View button.

Note that you receive the error message that is mentioned in the &quot;Symptoms&quot; section of this article, and then Microsoft Access quits.</li></ol>

Additional query words: pra IPF Invalid Page Fault restart

Keywords: kberrmsg kbbug kbnofix KB295242

-

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

© Microsoft Corporation. All rights reserved.