This is a multi-part message in MIME format.
------=_NextPart_000_01BC4EF9.0F818160
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Hi,
Sure, you can loop throught the collection, as suggested by Michael, but
you can also make error trapping to contribution and directly try a
CurrentDB( ).TableDefs("NameOfTable").Name, as example. If there is no
error (Err.Number =0), you can assume NameOfTable exist.
Hope it may help,
Vanderghast, Access MVP.
Quote:
> Hello all,
> To find one table in database, find it in documents container.
> This function return True if the table is in table container.
> Ex:
> If FindTable("Table Name") Then DoCmd DeleteObject A_TABLE, "Table Name"
> This example is write in Access 97.
> )Function FindTable(W_TableName As String) As Boolean
> ) Dim W_Doc As Document, W_DB As Database, W_Container As
> Container
> ) Set W_DB = CurrentDb
> ) Set W_Container = W_DB.Containers!Tables
> ) FindTable = False
> ) For Each W_Doc In W_Container.Documents
> ) If W_Doc.Name = W_TableName Then FindTable = True
> ) Next
> )End Function
> Michael A. Michalski escreveu no artigo
Quote:
> ki>... ...
> >I need to test for the existence of a table before I attempt to delete
> it.
> >Because these table are used in conjunction with reports in preview
mode,
> I
> >am unable to delete them as part of the button generating the report.
> >I would like to use DeleteObject but cannot unless I can verify the
> >existence of a table first. Some tables are not always generated in the
> >report generation. A peer suggested the following that does not work:
> >If Not IsNull (DLookup("[Name]","MSysObjects","[Name} ='Table Name'"))
> Then
> > DoCmd DeleteObject A_TABLE, "Table Name"
> >End If
> >Any takers?
> >--
> >Michael A. Michalski
> >Crescendo Enterprises
> >Consulting Services for Small Business
> >419-524-1022
------=_NextPart_000_01BC4EF9.0F818160
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<html><head></head><BODY bgcolor=3D"#FFFFE8"><p><font size=3D2 =
color=3D"#000000" face=3D"Arial">Hi,<br><br>Sure, you can loop throught =
the collection, as suggested by Michael, but you can also make error =
trapping to contribution and directly try a <b>CurrentDB( =
).TableDefs("NameOfTable").Name</b>, as example. If there is =
no error (Err.Number =3D0), you can assume NameOfTable =
exist.<br><br>Hope it may help,<br>Vanderghast, Access =
MVP.<br><br>Wladimir Cesar Bianchi <<font =
color=3D"#000000">> wrote in article <<font =
nt color=3D"#000000">>...<br>> Hello all,<br>> <br>> To find =
one table in database, find it in documents container. <br>> This =
function return True if the table is in table container.<br>> Ex: =
<br>> If FindTable("Table Name") Then DoCmd DeleteObject =
A_TABLE, "Table Name"<br>> <br>> This example is write =
in Access 97.<br>> <br>> )Function FindTable(W_TableName As =
String) As Boolean<br>> =
) Dim W_Doc As =
Document, W_DB As Database, W_Container As<br>> Container<br>> =
) Set W_DB =3D CurrentDb<br>> ) =
Set W_Container =3D W_DB.Containers!Tables<br>> =
) FindTable =3D False<br>> ) =
For Each W_Doc In W_Container.Documents<br>> =
) If W_Doc.Name =
=3D W_TableName Then FindTable =3D True<br>> ) =
Next<br>> )End Function<br>> Michael A. Michalski =
escreveu no artigo <<font =
color=3D"#000000"><br>> ki>... ...<br>> >I need to test for =
the existence of a table before I attempt to delete<br>> it.<br>> =
>Because these table are used in conjunction with reports in preview =
mode,<br>> I<br>> >am unable to delete them as part of the =
button generating the report.<br>> ><br>> >I would like to =
use DeleteObject but cannot unless I can verify the<br>> =
>existence of a table first. Some tables are not always =
generated in the<br>> >report generation. A peer suggested =
the following that does not work:<br>> ><br>> >If Not IsNull =
(DLookup("[Name]","MSysObjects","[Name} =
=3D'Table Name'"))<br>> Then<br>> > DoCmd DeleteObject =
A_TABLE, "Table Name"<br>> >End If<br>> ><br>> =
>Any takers?<br>> >--<br>> >Michael A. Michalski<br>> =
>Crescendo Enterprises<br>> >Consulting Services for Small =
Business<br>> >419-524-1022 <br>> <br>> <br>> </p>
</font></font></font></font></font></font></font></body></html>
------=_NextPart_000_01BC4EF9.0F818160--