[AccessD] Does table exist?

StaRKeY StaRKeY at Wanadoo.nl
Thu Mar 20 14:47:00 CST 2003


Ah, okay:-)

> That day a man stops looking for alternatives, he's old.
As in..old & wise?:-) How many female alternatives do you need to figure
them out?

How about this one:

Function TableExists(str As String) As Boolean
On Error Resume Next
Dim tbl As DAO.TableDef
    Set tbl = CurrentDb.TableDefs(str)
    TableExists = Not CBool(Err)
    Err = 0
    Set tbl = Nothing
End Function

And there are actually more table types to worry about Tim, since you can
have oracle/sql server etc. linked tables they all have their own
characteristic type, go figure;-)

Have fun,
Eric S.

-----Original Message-----
From: accessd-admin at databaseadvisors.com
[mailto:accessd-admin at databaseadvisors.com]On Behalf Of t tom
Sent: donderdag 20 maart 2003 20:31
To: accessd at databaseadvisors.com
Subject: Re: [AccessD] Does table exist?


Hi Eric

Sorry,  didn't mean to be persistent  just having fun with this.
Its just that it looks more compact and doesn't use a loop.
Until I came across this code I did use the For Each .....Next construct.

 and thanks gustav,  how about if I rewrite this way

Public Function CheckTableExist (strTableName As String) As Boolean

Dim strCriteria As String
strCriteria = "name = '" & strTableName & "'" & " and (type=1 or type=6)"
CheckTableExist = IIf(DCount("[ID]", "MSysObjects", strCriteria) > 0, True,
False)

End Function


Tomt

----- Original Message -----
From: "Arthur Fuller" <artful at rogers.com>
To: <accessd at databaseadvisors.com>
Sent: Thursday, March 20, 2003 10:33 AM
Subject: RE: [AccessD] Does table exist?


> Then may all your women be young, Gustav.
>
>
> "Those who would sacrifice liberty for security deserve neither."
> -- Benjamin Franklin
>
> -----Original Message-----
> From: accessd-admin at databaseadvisors.com
> [mailto:accessd-admin at databaseadvisors.com] On Behalf Of Gustav Brock
> Sent: March 20, 2003 11:56 AM
> To: StaRKeY
> Subject: Re: [AccessD] Does table exist?
>
>
> Hi Eric
>
> That day a man stops looking for alternatives, he's old.
> The same goes for women.
>
> /gustav
>
>
> > Just out of curiousity Tom, why are you so persistent in using the
> > msysobjects while we are being offered a pretty easy down to earth
> > Access objectmodel? (I'm sorry if I came on too strong about the
> > sample)
>
> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com

_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com


---
Message is tested virus free
Virus Database (VPS): 19-3-2003
Tested on: 20-3-2003 21:40:44

(c) 2000-2003 ALWIL Software.
http://www.avast.com




More information about the AccessD mailing list