table in database

A

alekm

Hi,
how can I determine, through code, whether table_temp exists in my database
(or it is already deleted)?
Thanx

alek_mil
 
J

Justin Hoffman

alekm said:
Hi,
how can I determine, through code, whether table_temp exists in my
database
(or it is already deleted)?
Thanx

alek_mil


Paste the function into a new module, make sure you have a reference to the
DAO object library and make sure you compile the code. Then you use it as
shown below:

If TableExists("table_temp") Then
MsgBox "It exists"
Else
MsgBox "It doesn't exist"
End If


Function TableExists(strTableName As String) As Boolean

On Error GoTo Err_Handler

Dim dbs As DAO.Database
Dim tdf As DAO.TableDef

Set dbs = CurrentDb

For Each tdf In dbs.TableDefs
If tdf.Name = strTableName Then
TableExists = True
Exit For
End If
Next tdf

Exit_Handler:
On Error Resume Next
Set tdf = Nothing
Set dbs = Nothing

Exit Function

Err_Handler:
MsgBox Err.Description, vbExclamation, "Error No: " & Err.Number
Resume Exit_Handler

End Function
 
J

Jeff Boyce

An alternative to making/deleting a temp table (if I read between the lines
of your post correctly) would be to create a permanent table, then append
records to and delete records from that table.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top