Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Table in Database 1

Status
Not open for further replies.

chris9

Programmer
Feb 11, 2003
32
US
I have a form that is creating a table and I want to check and make sure the table name that is entered into [Form]![Form1]![Text0] is in the database. If the table already exists I want to delete it because otherwise the new data that I am importing gets added to the current table. So basically I would like to know how you check to see if the new table you are creating already exists?
Thanks in advanced
 
check out the 'tabledefs' collection.

Something along the lines of

on error resume next
dim MyTdf as tabledef
set mytdf = nothing
set mytdf = currentdb.tabledefs("TableName")
TableExists = not mytdf is nothing
 
Why not attempt to Delete the Table each time before the new Table is created whether it exists or not. Just remember that if you are using Error Handling to turn it back on after the DeleteObject Method.

Dim strDeleteTable As String
On Error Resume Next
strDeleteTable = Me!txtYourControlName
DoCmd.DeleteObject acTable, strDeleteTable

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top