Microsoft Knowledge Base Email Alertz

There appears to be no immediate effect when you programmatically set the ANSI Query Mode property.

Search KbAlertz

Advanced Search

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]











Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

Article ID: 282398 - Last Review: October 11, 2006 - Revision: 2.2

ACC2002: No Effect When You Programmatically Set ANSI-92 Mode

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

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

On This Page

SYMPTOMS

There appears to be no immediate effect when you programmatically set the ANSI Query Mode property.

CAUSE

This behavior occurs because Microsoft Access determines the query mode when the database is opened. Therefore, any changes to this property do not take effect until the database is closed and then reopened.

RESOLUTION

To resolve this issue, close the database and reopen it.

STATUS

This behavior is by design.

MORE INFORMATION

The ANSI Query Mode property allows you to programmatically specify whether Access should use Microsoft SQL Server-compatible (ANSI-92) syntax when running queries in the current database. ANSI-92 mode introduces new syntax features that allow you to create SQL Server-compliant queries. This setting can also be modified on the Tables/Queries tab in the Options dialog box. When you manually change the query mode in the Options dialog box, Access automatically closes the database, compacts it, and then reopens it. If you programmatically set the property, you must close and reopen the database afterwards for the new setting to take effect.

Note that changing this setting may cause existing queries to return unexpected results, or to not run at all. Microsoft recommends that you make a backup copy of the database and compact it before altering the query mode.

Steps to Reproduce the Behavior

  1. Open the sample database Northwind.mdb.
  2. Press CTRL+G to open the Microsoft Visual Basic Editor.
  3. Type the following statement in the Immediate window, and then press Enter:
    Application.SetOption "ANSI Query Mode", True
    					
  4. Quit the Visual Basic Editor and return to Access.
  5. To confirm that the ANSI-92 Query Mode is turned on, click Options on the Tools menu, and then click Tables/Queries.

    Notice that the This database check box under SQL Server Compatible Syntax (ANSI-92) is selected.
  6. Create the following query:
    SELECT CategoryID, CategoryName 
    FROM Categories 
    WHERE CategoryName LIKE "B%";
    					
    NOTE: This query uses the ANSI-92-compliant "%" wildcard character instead of the Jet "*" wildcard character.

  7. Save the query as Query1 and then run it.

    Notice that zero records are returned, even though one record does match the query's criteria.
  8. Close the database and reopen it.
  9. Run Query1 again.

    Notice that one record is now returned.

REFERENCES

For more information about ANSI-92 SQL mode, click Microsoft Access Help on the Help menu, type ansi-92 sql mode in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

APPLIES TO
  • Microsoft Access 2002 Standard Edition
Keywords: 
kbprb KB282398
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate