PRB: Syntax Error in Help Example of Kill Statement (1.x, 2.0)

    Article ID: Q131880
    Creation Date: 22-JUN-1995
    Revision Date: 19-SEP-1996

    The information in this article applies to:

    • Microsoft Access version 1.0, 1.1, 2.0

    SYMPTOMS

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

    The "Example" section of the "Kill Statement" topic in the Microsoft Access Help system has a syntax error in the Access Basic code. The example uses an End statement instead of an Exit Function statement just before the Errhandler routine (Errhandler:). The End statement can cause a run-time error when you paste the code into a new function and then run the function using a RunCode action in a macro.

    RESOLUTION

    The "Example" section of the "Kill Statement" topic reads as follows:

       Kill Statement Example
    
       This example uses Kill to remove a user-specified file.
    
       On Error GoTo Errhandler   ' Set up error handler.
       DelFile = UCase(InputBox("Enter file name you want deleted."))
       If Len(DelFile) Then ' Check for entry.
          Ansr = MsgBox("Sure you want to delete " & DelFile & "?", 4)
          If Ansr = 6 Then  ' User chose "Yes."
             Msg = "Deleting " & DelFile & " from your disk."
             Kill DelFile   ' Delete file from disk.
          Else
             Msg = DelFile & " was not deleted."
          End If
       Else
          Msg = "You didn't enter a file name."
       End If
       MsgBox Msg           ' Display message.
       End
    
       Errhandler:
          If Err = 53 Then  ' Error 53 is "File not Found."
             Msg = "Sorry, the file you named could not be found."
          Else
             Msg = "Sorry, unable to delete file."
          End If
          Resume Next
    
    
    In the example above, replace the End statement just above the Errhandler routine with the Exit Function statement so that the code reads as follows:

       MsgBox Msg            ' Display message.
       Exit Function
    
       Errhandler:
    
    
    STATUS

    This behavior does not occur in Microsoft Access for Windows version 7.0.

    REFERENCES

    For more information about the Kill statement, search for "Kill" then "Kill Statement" using the Microsoft Access Help menu.


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.
©1997 Microsoft Corporation. All rights reserved. Legal Notices.

Additional reference words: 1.00 1.10 2.00
KBCategory: kbusage
KBSubcategory: DcmHlp