Delete Table...

L

learning_codes

Hi,

I'm wondering if you can help me how to check the "Table One" before
deleting the table. If there is no table three, the message box
showing "need to create table 3". The most thing I need to know how
to check the table One before delete the table using command button.


DoCmd.DeleteObject acTable, "Table One"
DoCmd.DeleteObject acTable, "Table Two"

I would appreciate your help.
Thanks...
 
J

John W. Vinson

Hi,

I'm wondering if you can help me how to check the "Table One" before
deleting the table. If there is no table three, the message box
showing "need to create table 3". The most thing I need to know how
to check the table One before delete the table using command button.


DoCmd.DeleteObject acTable, "Table One"
DoCmd.DeleteObject acTable, "Table Two"

I would appreciate your help.
Thanks...

I'm not sure I understand. You say you need to check Table One, then "if there
is no table three". Why are you deleting and creating tables (apparently
routinely) in any case? That's unusual, and generally not necessary!

The simplest way to check for the existance of a table is probably to see if
it's in the (undocumented and concealed) MSysObjects table:

IF IsNull(DLookUp("[Name]", "MSysObjects", "[Type] = 1 AND [Name] = 'Table
One'") Then
<the table does not exist>
Else
<it does exist>
End If
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/Forums/en-US/accessdev/
http://social.answers.microsoft.com/Forums/en-US/addbuz/
and see also http://www.utteraccess.com
 
L

learning_codes

I'm wondering if you can help me how to check the "Table One" before
deleting the table.    If there is no table three, the message box
showing "need to create table 3".    The most thing I need to know how
to check the table One before delete the table using command button.
   DoCmd.DeleteObject acTable, "Table One"
   DoCmd.DeleteObject acTable, "Table Two"
I would appreciate your help.
Thanks...

I'm not sure I understand. You say you need to check Table One, then "if there
is no table three". Why are you deleting and creating tables (apparently
routinely) in any case? That's unusual, and generally not necessary!

The simplest way to check for the existance of a table is probably to seeif
it's in the (undocumented and concealed) MSysObjects table:

IF IsNull(DLookUp("[Name]", "MSysObjects", "[Type] = 1 AND [Name] = 'Table
One'") Then
   <the table does not exist>
Else
   <it does exist>
End If
--

             John W. Vinson [MVP]
 Microsoft's replacements for these newsgroups:
 http://social.msdn.microsoft.com/Forums/en-US/accessdev/
 http://social.answers.microsoft.com/Forums/en-US/addbuz/
 and see alsohttp://www.utteraccess.com

Thank you so much.

Will it possible to have the link or import tables from other database
if the database has the tables available before import into the new
database.

I would like to see if my new database can check and alert me if need
to add table to other database before import or link the tables from
other database to my new database.
Sometime, I get error and couldnt find the table 1 or 2 from other
database because I forget to add table 1 and 2 on my old database. It
will alert me if need to add table 1 before
importing or linking to table 1 from old database to new database.

DoCmd.TransferDatabase acImport, "Microsoft Access", "Other
Database", acTable, "Table1-Other Database", "Table1-New Database",
False

DoCmd.TransferDatabase acLink, "Microsoft Access", "Other
Database", acTable, "Table2-Other Database", "Table2-New Database",
False


Your help would be much appreciated.
Thanks...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top