Results 1 to 5 of 5
  1. #1
    BatmanMR287 is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Jan 2014
    Posts
    69

    Deleting Linked Excel sheet

    I have a database that links to an excel sheet and take data from it. For a fail safe i put deletes in several places in case of user error to make sure the sheet is deleted. If it is already deleted the other deletes don't act well.
    I need to write a conditional iff statement that if it doesn't exist it ignores the delete call. Not sure how to structure it.

    Private Sub Command3_Click()
    DoCmd.DeleteObject acTable, "Sheet1"


    DoCmd.Close acForm, "District Select Form"
    End Sub

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Options:

    1. error handler

    2. loop through tables collection

    3. On Error Resume Next

    Review http://www.tek-tips.com/viewthread.cfm?qid=1070803
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    BatmanMR287 is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Jan 2014
    Posts
    69
    Can't read that site. Continuous popups on page keep me from reading it.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Yeah, that was rather annoying. Had to avoid hovering cursor over posts. Kept off to the right side and scrolled. I managed to read enough to get the gist of content.

    Do the Bing search and see what else there is.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    BatmanMR287 is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Jan 2014
    Posts
    69
    Got it from the above page, after a few minutes the popups calm down.

    Private Sub Form_Close()
    On Error Resume Next
    DoCmd.DeleteObject acTable, "Sheet1"
    On Error GoTo 0
    End Sub

    This one doesn't care if the sheet is there or not. Thanks for the direction June 7.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 26
    Last Post: 01-08-2013, 04:55 PM
  2. From Recordset to excel sheet
    By mark71 in forum Programming
    Replies: 1
    Last Post: 12-10-2012, 03:40 PM
  3. Dropping/deleting linked tables in VBA or query
    By dumbledown in forum Access
    Replies: 3
    Last Post: 04-05-2012, 08:43 AM
  4. Deleting linked tables
    By hertfordkc in forum Database Design
    Replies: 8
    Last Post: 09-20-2011, 02:58 PM
  5. Replies: 0
    Last Post: 02-21-2008, 09:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums