Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2004
    Location
    California
    Posts
    502

    Unanswered: Delete File and Linking files Access 2003

    Code:
    Private Sub Command5_Click()
    DoCmd.OpenReport "rptCBCapoBeach", acViewPreview, ""
    On Error Resume Next
    Kill "C:\flw\Access\qryCBCapoBeachProg.xls"
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel2003, "qryCBCapoBeachProg", "C:\flw\Access\", True
    MsgBox "Exported CAPO BEACH Program"
    End Sub
    This works well the first time I use it only after I manually delete all of the files first in C:\flw\Access\
    Then I open Freelance Graphics and open the charts that are linked to the exported Excel 5-7 format (whatever that is) file named qryCBCapoBeachProg.xls but the charts wont open.
    The word Link is not highlighted and the program will continue in this mode without shutting down for hours. I must use the task bar to close the program.
    This is not working at all! (Kill "C:\flw\Access\qryCBCapoBeachProg.xls")
    Im using Access 2003 and Lotus Freelance Graphics under Windows 7 in both in x86 mode.
    If I can successfully delete the file as shown in the above code I would not have any problems.
    I cant figure it out.

    Thanks . . . Rick

  2. #2
    Join Date
    Mar 2009
    Posts
    5,441
    Provided Answers: 14
    The fist thing to do is to remore or comment the line:
    Code:
    On Error Resume Next
    and see what kind of error (if any) is raised.
    Have a nice day!

  3. #3
    Join Date
    Sep 2006
    Location
    Surrey, UK
    Posts
    994
    Provided Answers: 2
    Silly question, but does the file exist? VBA generally refuses to delete files that it cannot find.
    You could always try replacing
    Code:
    Kill "C:\flw\Access\qryCBCapoBeachProg.xls"
    with
    Code:
    If Dir("C:\flw\Access\qryCBCapoBeachProg.xls") <> "" Then Kill "C:\flw\Access\qryCBCapoBeachProg.xls"
    10% of magic is knowing something that no-one else does. The rest is misdirection.

  4. #4
    Join Date
    Mar 2004
    Location
    California
    Posts
    502

    How about the wrong File name!!!!

    My own fault.

    The file name in the KILL code was one letter different that the export file name.

    My mistake.

    Thanks everyone.

    Rick

  5. #5
    Join Date
    Mar 2009
    Posts
    5,441
    Provided Answers: 14
    You're welcome!
    Have a nice day!

Posting Permissions

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