J
Jim Russell
Two questions re your function (just for my own education):
1. Why loop through all tables? If TableDefs is a collection, could you not
use
MyDB.TableDefs(strTableName) to see if it exists?
2. Since MyDB is local, is any purpose served by "Set MyDB = Nothing"? Won't
exiting the function have the same effect?
Thanks!
From: "Rick Brandt" <[email protected]>
Subject: Re: Existence of table
Date: Friday, June 27, 2003 7:50 AM
Function TableExists(strTableName As String) As Boolean
Dim tbl As TableDef
Dim MyDB As Database
Set MyDB = CurrentDb
For Each tbl In MyDB.TableDefs
If tbl.Name = strTableName Then TableExists = True
Next tbl
Set MyDB = Nothing
End Function
1. Why loop through all tables? If TableDefs is a collection, could you not
use
MyDB.TableDefs(strTableName) to see if it exists?
2. Since MyDB is local, is any purpose served by "Set MyDB = Nothing"? Won't
exiting the function have the same effect?
Thanks!
From: "Rick Brandt" <[email protected]>
Subject: Re: Existence of table
Date: Friday, June 27, 2003 7:50 AM
Laura said:I am in the process of writing a routine that uses CreateTableDef("tblName")
but am unable to figure out how to check if a table already exists - I get
an error message, obviously, if I try to create it a second time.
Laura
Function TableExists(strTableName As String) As Boolean
Dim tbl As TableDef
Dim MyDB As Database
Set MyDB = CurrentDb
For Each tbl In MyDB.TableDefs
If tbl.Name = strTableName Then TableExists = True
Next tbl
Set MyDB = Nothing
End Function