finding a table

J

JMG

Hello

Is there a command in VBA so that Access will search for
a table (eg "addresses") inside the database and then
return either a Yes/No value if the table exists?

Ideally, this is what I want to do. Where I am stumped is
in brackets

Sub x()

Dim questions As ??

[question = Does table "addresses" exist?]
IF questions = Yes Then
DoCmd.DeleteObject acTable, "addresses"
Else
....


Thanks in advance
JMG
 
A

Allen Browne

There is not one built in, but paste the function below into a standard
module, and you can use it like this:
If TableExists("addresses") Then


Function TableExists(strTable As String) As Boolean
Dim varDummy As Variant
On Error Resume Next
varDummy = CurrentDb().TableDefs(strTable)
TableExists = (Err.Number = 0&)
End Function
 

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

Top