IsTable




If TableExists(strTableName) Then MsgBox strTableName & " found." _
Else MsgBox strTableName & " Not found."
'___________________________________________________________


Private Function TableExists(TableName) As Boolean
Dim dbMyDB As Database
Dim rsTemp As Recordset
On Error Goto NotFound
If TableName <> "" Then Set rsTemp = _
dbMyDB.OpenRecordset(TableName)
'If the RS fails, it will quickly pass over the

'true statement below.

TableExists = True
NotFound:
End Function
'___________________________________________________________


'I have VERY often seen people use the standard routine of

'going through EACH and EVERY table comparing each one till

'they get the the end, as in

For Each MyTable in DB.TableDefs
if MyTable.Name = strNameImLookingFor then
TableExists = true
Exit For
end if
Next

This is NOT the way to do this. You will unecesesarily use up
yours as well as your users' very valuable time.
Use this function. Make it private. When you pass the name
of the table you need to check for into this routine, the
recordset will either retrieve it, with a quickness, or it
will error out, which is even quicker.
If you have this in a private function, the erroring out will
equate to it returning a negative response for the table search.
I might add that this technique works superbly with field searches
as well (such as Serial No, credit cards, socials, phone numbers,etc).
And, there you have it.











( istable.html )- by Paolo Puglisi - Modifica del 17/12/2023