Hi
Here is my problem. I am writing a utility that will verify that my database(Access2000) contains all the relavent tables, fields, data etc. I want to be able to check if a table exist and if it does not create it so here is what I have.
Private hDB As New ADODB.Connection
Private Sub CheckTables
On Error GoTo ErrHandler
hDB.ConnectionString = sDBConnection & App.Path & "\TestDB.mdb"
hDB.Mode = adModeReadWrite
hDB.Open
hDB.Execute ("Create Table Junk"
Exit Sub
ErrHandler:
Debug.Print Err.Description & Err.Number
End Sub
This works fine when the table doesn't exist, but if it does exist I get the error:
Table 'Junk' already exists.-2147217900
which again is fine as I could just trap the error and continue on with my business. The problem I have with this is the error code is not just specific to the 'table exists' message so I don't want to trap it that way. Is there a better way to check for the tables presents ie an SQL command that I have not thought of etc etc. Thanks in advance.
Tom Anything is possible, the problem is I only have one lifetime.
Here is my problem. I am writing a utility that will verify that my database(Access2000) contains all the relavent tables, fields, data etc. I want to be able to check if a table exist and if it does not create it so here is what I have.
Private hDB As New ADODB.Connection
Private Sub CheckTables
On Error GoTo ErrHandler
hDB.ConnectionString = sDBConnection & App.Path & "\TestDB.mdb"
hDB.Mode = adModeReadWrite
hDB.Open
hDB.Execute ("Create Table Junk"
Exit Sub
ErrHandler:
Debug.Print Err.Description & Err.Number
End Sub
This works fine when the table doesn't exist, but if it does exist I get the error:
Table 'Junk' already exists.-2147217900
which again is fine as I could just trap the error and continue on with my business. The problem I have with this is the error code is not just specific to the 'table exists' message so I don't want to trap it that way. Is there a better way to check for the tables presents ie an SQL command that I have not thought of etc etc. Thanks in advance.
Tom Anything is possible, the problem is I only have one lifetime.