Check if Access Table exists - 2007

jsjones

New member
Local time
Yesterday, 19:05
Joined
Aug 18, 2011
Messages
2
I am using Access 2007.

What would be the correct syntax to use in vba module to check if an access table exists?

Example:
If accesstable1 exists then
xxx
Else
yyy
End If

This seems like it should be a very basic function, but I have not been able to find it.

Thanks!!
 
Here's a function you can use...
Code:
function TableExists(name as string) as boolean
  TableExists = dcount("*", "MSysObjects", "Name = '" & name & "' AND Type = 1")
end function
Cheers,
Mark
 
That worked, and simple.
Thanks!!!
 
Here's a function you can use...
Code:
function TableExists(name as string) as boolean
  TableExists = dcount("*", "MSysObjects", "Name = '" & name & "' AND Type = 1")
end function
Cheers,
Mark

Hello Mark,

You sure it's not type = 6? On my accdb all my tables are type 6 for some reason.

Cheers,
Sam
 

Users who are viewing this thread

Back
Top Bottom