[AccessD] Does table exist?

Gustav Brock gustav at cactus.dk
Thu Mar 20 05:43:00 CST 2003


Hi Tom

Nice try, Tom, but Type = 1 only reveals internal tables, not attached.
Also, minor point, I believe DCount always return a value, zero if no
records were found; thus the Nz() is not needed - you call it "moot" I
think ...

/gustav


> OK , Lets try again ( making code a little less squeaky , now only checks for tables )

> Public Function CheckTableExist(strTableName As String) As Boolean
> Dim strCriteria As String

> strCriteria = "name = '" & strTableName & "'" & " and type=1"
> If Nz(DCount("[ID]", "MSysObjects", strCriteria), 0) > 0 Then
>     CheckTableExist = True
> Else
>     CheckTableExist = False
> End If
> End Function


> Tomt
>   ----- Original Message ----- 
>   From: StaRKeY 
>   To: accessd at databaseadvisors.com 
>   Sent: Wednesday, March 19, 2003 1:27 PM
>   Subject: RE: [AccessD] Does table exist?


>   Lets not(!)...Marc

> Fyi this table also contains the names of forms, modules, classes or in short Access objects... in case the name of a table resembles another object any object for that matter this code will not
> work properly. Ofcourse, if you are sure it's of no importance to you go ahead and use squeeky code:-) (no offense Tom)

> The code would get better if you also use the special ID's used for tables but then again there are several since you can have hidden/linked/system tables... all having their own id... easier to
> just use code mentioned earlier.




More information about the AccessD mailing list