
add new table unless already exists
This code will determine whether or not a
table is in a database by cycling through all
of the table names in a database.
Call:
If Not IsTableInDB("MyTable") Then
'Append Code
Else
'Table is already there
End If
************
Private Function IsTableInDB(TableName As String) As Boolean
Dim iCount as Integer
'Note: MyDatabase is a Public Database object that has already been set
With MyDatabase
For iCount = 0 To .TableDefs.Count -1
If .TableDefs(iCount).Name = TableName Then
IsTableInDB = True
Exit Function
End If
Next
End With
IsTableInDB = False
End Function
--
Later,
Jody
http://www.visual-statement.com/vb
Quote:
>Hello,
>I want my program to check first to see if a table exists in a database,
>and if it already does then go ahead and add records. If the table does
>not exist, I want the program to add the table to the database, add
>fields to the table, and then add records. I'm having trouble writing
>the code that tells the program to check to see if the table already
>exists. Can any one give me a pointer?
>Thanks in advance,
>Darren.