finding a table

  • Thread starter Thread starter JMG
  • Start date Start date
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
 
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
 
Back
Top