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

    VBA If Statement


    I need an If statement for this vba line in an access database.

    DoCmd.DeleteObject acTable, "Sheet1"

    Sometimes "Sheet1" is not there and without the If statement it pops up an error window. Apparently I am writing it wrong.

  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
    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
    Opps, sorry June7. I should have said it is actually a linked Excel file. Deleting it from the access database severs the link.

  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
    Example code should be adaptable.
    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
    DubCap01 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2014
    Location
    Dubbo, Australia
    Posts
    104
    You could also try this, it works on any of my bits of VBA...

    On Error Resume Next
    CurrentDb.Execute "Drop Table Sheet1", dbFailOnError
    'and here comes the rest of your code...

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

Similar Threads

  1. Replies: 11
    Last Post: 04-29-2015, 01:38 PM
  2. IFF OR Statement
    By tennisbuck in forum Access
    Replies: 3
    Last Post: 05-15-2014, 10:36 AM
  3. if statement in sql statement, query builder
    By 54.69.6d.20 in forum Access
    Replies: 4
    Last Post: 09-11-2012, 07:38 AM
  4. Replies: 7
    Last Post: 08-17-2011, 01:49 PM
  5. If Then Statement Help
    By Kapelluschsa in forum Programming
    Replies: 5
    Last Post: 08-11-2010, 09:24 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