This lesson comes as part of a series on building Microsoft Access Applications
There may come a time where you’re creating an MS Access application and you need to systematically check to see if a table already exists.
This handy function does just that.
It’s simple, and effective – which is the best kind of code.
Just add this function to a module in your VBA.
Function TableExists(strTableName As String) As Boolean On Error Resume Next TableExists = IsObject(CurrentDb.TableDefs(strTableName)) End Function
Then use the below method to check to see if that table exists:
If TableExists("My_Table_Name") = False Then 'Change the table name to your table 'Do Something Fun Else 'Do Something Else Fun End If