Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2002
    Posts
    5

    Unanswered: How to delete file from Access

    I want to export a table as a spreadsheet: fine on that, but if the file already exists, nothing happens, not even an error.
    So I want to delete the file if it already exists, but haven't a clue how to do it.

  2. #2
    Join Date
    Aug 2002
    Location
    Charlotte NC
    Posts
    665

    Re: How to delete file from Access

    Originally posted by carolineknights
    I want to export a table as a spreadsheet: fine on that, but if the file already exists, nothing happens, not even an error.
    So I want to delete the file if it already exists, but haven't a clue how to do it.
    Are you running a macro to do the export? If you are you can set warnings off and it should just overwrite the file.
    Please explane a bit more so maybe I can get a better idea of whats happening.
    Regards Jim

  3. #3
    Join Date
    Aug 2002
    Location
    Québec, Canada
    Posts
    109
    If you use code, (and since you use FileSystemObject ), here a short example on how to use FileSystemObject to look for existing file and to delete file:

    Code:
        'Add a reference to Scripting Runtime
        
        Dim fso As New FileSystemObject
        
        If fso.FileExists("C:\Jeff\FICHTEST.txt") Then
            If MsgBox("That file exist, delete?", vbYesNo) = vbYes Then
                fso.DeleteFile ("C:\Jeff\FICHTEST.txt")
            End If
        Else
            MsgBox "Do not exist"
        End If
    
        set fso = nothing
    JefB - hope it helps
    Last edited by JefB; 09-12-02 at 10:31.

  4. #4
    Join Date
    Sep 2002
    Posts
    5

    Talking

    JefB, you're a star!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •