ACC: "Invalid Use of Null" with SysCmd() Function

Last reviewed: May 21, 1997
Article ID: Q124160
The information in this article applies to:
  • Microsoft Access versions 1.1, 2.0

SYMPTOMS

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

When you use the SysCmd() function in Access Basic code, you may receive the error message "Invalid use of Null."

CAUSE

This error message occurs when the SysCmd() function returns a null value and the return variable is declared as any data type other than Variant.

RESOLUTION

Make sure that the return variable for each call to the SysCmd() function has a Variant data type.

STATUS

This behavior no longer occurs in Microsoft Access version 7.0.

MORE INFORMATION

The only Access Basic data type that can hold a null value is the Variant data type. Since the SysCmd() function frequently returns a null value, the return variable should have the Variant data type, as in the following example:

   Dim ReturnVal As Variant
   ReturnVal = SysCmd(4, "Status Bar Text Message")

NOTE: In Microsoft Access version 2.0, you can replace the "4" in the above example with "SYSCMD_SETSTATUS" (a new constant in version 2.0).

If you do not explicitly declare the return variable's data type, it is implicitly declared as a Variant data type, so the following example works as well:

   Dim ReturnVal
   ReturnVal = SysCmd(4, "Status Bar Text Message")

Steps to Reproduce Behavior

  1. Start Microsoft Access and open any database.

  2. Create a new module and enter the following line in the module's Declarations section:

          Option Explicit
    

  3. Enter the following code in the module:

          Sub SysCmdDemo1 ()
             Dim ReturnVal As Integer
             ReturnVal = SysCmd(4, "SysCmd Fails")
          End Sub
    
    

  4. From the View menu, choose Immediate Window.

  5. Type the following line in the Immediate window and then press ENTER:

          SysCmdDemo1
    

    You receive the error message stated above.

REFERENCES

For more information about using the SysCmd() function in Microsoft Access version 2.0, search for "SysCmd," and then "SysCmd Function" using the Microsoft Access 2.0 Help menu.


Keywords : kberrmsg kbusage SynFnc
Version : 1.1 2.0
Platform : WINDOWS
Hardware : X86
Issue type : kbprb
Resolution Type : Info_Provided


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