Microsoft KB Archive/119807

= ACC2: SQL Statement in Macro Condition Causes GP Fault =

Article ID: 119807

Article Last Modified on 7/5/2002

-

APPLIES TO


 * Microsoft Access 2.0 Standard Edition

-



This article was previously published under Q119807



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



SYMPTOMS
When you run a macro that has an SQL statement as part of a conditional expression, you may receive a general protection (GP) fault.



RESOLUTION
Use the DLookup function, or a user-defined function, instead of an SQL statement to return the value to be used in the conditional expression.



STATUS
Microsoft has confirmed this to be a problem in Microsoft Access version 2.0. This behavior no longer occurs in Microsoft Access version 7.0.



MORE INFORMATION
SQL statements cannot be used in expressions within macro conditions. You must instead use a function that only returns one value.

Steps to Reproduce Problem
  Create the following new table and then save it as Table1. Do not create a primary key on the table.

     Table: Table1 Field Name: Field1 Data Type: Number  View the table in Datasheet view and enter 5 in the first record. Do not enter any other records.  Create the following new macro and then save it as Macro1:

     Macro Name   Condition                        Macro Action ---     Macro1       (Select Field1 from Table1;)>1   Beep  Run the macro. You will receive a GP fault.</li></ol>

<div class="references_section">