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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Does the Table Exist 1

Status
Not open for further replies.

MacroAlan

Programmer
Dec 4, 2006
134
US
In my project, I create one of 3 Temporary named tables depending on where the data comes from.

How do I check to see if a table exists so that I can do something with it?

I started on:
Code:
If Exists "tempTableX" then
but I do not think that is the correct syntax.

Alan

 
You can look up a system table:

[tt]DlookUp("Name","MsysObjects","Name='tempTableX'")[/tt]
 
Remou's is great for local DBases (*)
But, in case not ...

Dim db As dAO.Database
Dim tbl as DAO.TableDef

Set db = OpenDatabase("C:\Docs & Settings\....mdb")
set tbl = db.TableDefs("tempTableX")
db.Execute "Insert Into tempTableX(...

xx:
Exit Sub
Error:
If err = 3025 Then 'Object don't exist (check the number?)
db.execute "CREATE TABLE tempTableX....,adExecuteNoRecords
Resume next
Else
Resume xx
End If

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top