Alex Rivera | Logout

Check if access table exists

Asked 2010-06-06T19:05:34.047
21

I want to log web site visits' IP, datetime, client and refferer data to access database but I'm planning to log every days log data in separate tables in example logs for 06.06.2010 will be logged in 2010_06_06 named table. When date is changed I'll create a table named 2010_06_07. But the problem is if this table is already created.

Any suggestions how to check if table exists in Access?

Edit
Report

1 Answer

10

Here's another solution, will be a bit faster than looping over all of the tables.

Public Function doesTableExist(strTableName As String) As Boolean
    Dim db As DAO.Database
    Dim td As DAO.TableDef
    Set db = CurrentDb
    On Error Resume Next
    Set td = db.TableDefs(strTableName)
    doesTableExist = (Err.Number = 0)
    Err.Clear
End Function
answered 2010-06-06T20:56:02.640

Your Answer