ACC2: SQL Statement in Macro Condition Causes GP Fault

Last reviewed: May 14, 1997
Article ID: Q119807
The information in this article applies to:
  • Microsoft Access version 2.0

SYMPTOMS

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

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

  1. 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
    
    

  2. View the table in Datasheet view and enter "5" (without quotation marks) in the first record. Do not enter any other records.

  3. Create the following new macro and then save it as Macro1:

          Macro Name   Condition                        Macro Action
          -----------------------------------------------------------
          Macro1       (Select Field1 from Table1;)>1   Beep
    
    

  4. Run the macro. You will receive a GP fault.

REFERENCES

Microsoft Access "User's Guide," version 2.0, Chapter 24, "Using Conditions in Macros," pages 620-623

For more information about using conditions in a macro, search for "Conditions," and then "Using Conditions in a Macro" using the Microsoft Access Help menu.


Additional query words: gpf
Keywords : kberrmsg kbusage McrCond
Version : 2.0
Platform : WINDOWS
Hardware : X86
Issue type : kbbug
Resolution Type : kbworkaround


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: May 14, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.