First, I must admit, that I am not trained in coding with VBA. I use MS Access macros and queries to build my application. I use some temporary import files, and need to either run a macro, or some VBA, to test if they exist, and then if they do, to delete them.
My table name is "TempImport1"
I've researched this via google searches and have come across some VBA that might work, but I am lost trying to figure out how to put the code into a module or a click sub button. I have cut/pasted VBA code under a button function in the past, and it worked, but I can't figure out why it's not working this time.
Honestly, I'm sure it's my lack of understanding of private vs public functions, as well as of course, the fact that I don't know VBA. Thank you for any advice you can provide.
Here's the code I'm trying to make work:
Expand|Select|Wrap|Line Numbers
- Function IsTable(sTblName As String) As Boolean
- 'does table exists and work ?
- 'note: finding the name in the TableDefs collection is not enough,
- ' since the backend might be invalid or missing
- On Error GoTo TrapError
- Dim x
- x = DCount("*", sTblName)
- IsTable = True
- Exit Function
- TrapError:
- Debug.Print Now, sTblName, Err.Number, Err.Description
- IsTable = False
- End Function