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.
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.
Why delete table?
Bing: Access VBA verify table exists
http://www.eraserve.com/tutorials/MS...ble_Exists.asp
http://stackoverflow.com/questions/3...-for-vb-macros
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.
Opps, sorry June7. I should have said it is actually a linked Excel file. Deleting it from the access database severs the link.
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.
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...