[AccessD] Does table exist?

Bobby Heid bheid at appdevgrp.com
Thu Mar 20 13:54:00 CST 2003


Another way that I have not seen here yet is something similar to:

	'this is OTOH
	on error resume next
	if db.tabledefs("tablename").name="" then
	   End If
	
	if err.number=(can't remember the # right now) then
	   TableExists=FALSE
	   Else
	   	TableExists=TRUE
	   End if

I don't know if this would be any faster, but it only has to look in a
collection, not run a query.

Bobby

-----Original Message-----
From: accessd-admin at databaseadvisors.com
[mailto:accessd-admin at databaseadvisors.com]On Behalf Of t tom
Sent: Thursday, March 20, 2003 2:31 PM
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




More information about the AccessD mailing list