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).
There appears to be no immediate effect when you programmatically set the ANSI Query Mode property.
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.
To resolve this issue, close the database and reopen it.
This behavior is by design.
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
- Open the sample database Northwind.mdb.
- Press CTRL+G to open the Microsoft Visual Basic Editor.
- Type the following statement in the Immediate window, and then press Enter:
Application.SetOption "ANSI Query Mode", True
- Quit the Visual Basic Editor and return to Access.
- 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. - 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.
- 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. - Close the database and reopen it.
- Run Query1 again.
Notice that one record is now returned.
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
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