Microsoft KB Archive/97622

{|
 * width="100%"|

PRB: Access Basic Does Not Support Yes and No Action Arguments
'Article ID: Q97622

Creation Date: 15-APR-1993

Revision Date: 19-SEP-1996' The information in this article applies to:


 * Microsoft Access versions 1.0, 1.1, and 2.0

SYMPTOMS

When you use the DoCmd statement in Access Basic, Microsoft Access does not recognize a Yes or No argument.

RESOLUTION

Use True for the argument instead of Yes, and use False instead of No. True and False are reserved words in Access Basic.

STATUS

This behavior is by design.

MORE INFORMATION

Even though macro actions accept the Yes or No action argument, Access Basic recognizes only True or False. However, the No argument will actually work because Microsoft Access does not recognize No. Therefore, a zero value is returned, which is interpreted as False. However, a Yes argument will also return a zero value, or False. Whether you use Yes or No, the argument will always be interpreted as False.

Steps to Reproduce Behavior

  Create the following module: '************************************************************ 'Declarations Section of the module. '************************************************************ Option Compare database 'Do not include the Option Explicit or you will receive an error 'message stating that you did not declare your variable &quot;no&quot;. 'This is because Access Basic does not recognize &quot;no&quot; as a 'reserved word. '============================================================= 'The following function will run a macro action that will turn 'warnings off, then attempt to turn them back on. '============================================================== Sub SetWarnings DoCmd SetWarnings No    'Turn warnings off DoCmd SetWarnings Yes   'Turn warnings on  End Sub   Run the sub procedure from the Immediate window by typing the following in the window and pressing ENTER: "SetWarnings" Try to delete a form, report, or table. Note that you did not receive any warnings. The sub procedure turned off the warnings, but did not recognize the Yes argument, so it did not turn them back on.  Change the sub procedure to: Sub SetWarnings DoCmd SetWarnings No        DoCmd SetWarnings True End Sub  Run the sub procedure from the Immediate window again. Try to delete a form, report, or table. Note that you will receive a warning. The sub procedure recognized the True argument and turned the warnings back on.
 * }

-

"THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED &quot;AS IS&quot; 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." '' ©1997 Microsoft Corporation. All rights reserved. Legal Notices.

''

Additional reference words: 1.00 1.10 2.00 warnings

KBCategory: kbprg

KBSubcategory: PgmOthr