Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 1 / April 2006

Tip: Looking for answers? Try searching our database.

Check For Table

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mike Charney - 17 Apr 2006 13:24 GMT
I have an Access data project. In this project I have a form that when
Access starts is loaded and this form has VBA code attached to it.

One of the first things I need to do is check if a table called tblimport
exists. If this table exists then I need to delete it. I have tried looking
through the web but I can not find a simple solution to this. I do not want
a separate module, just a couple lines of code.

Does the table exist, Yes = Delete it, No=Continue code execution.

Does any one know how to do this?

Thanks,
Mike
m charney at dunlap hospital dot org
Lyle Fairfield - 17 Apr 2006 13:51 GMT
> I have an Access data project. In this project I have a form that when
> Access starts is loaded and this form has VBA code attached to it.
[quoted text clipped - 12 lines]
> Mike
> m charney at dunlap hospital dot org

I have a one line solution but I guess that's too few.

Besides, 99 times out of 100, it's bad form and/or reflects poor design to
be constantly deleting and creating a table, and I wouldn't want to
propogate bad form or poor design.

What's that, you just asked or a solution and not a lecture? Tant pis!

Signature

Lyle Fairfield

Thelma Lubkin - 17 Apr 2006 14:18 GMT
:> I have an Access data project. In this project I have a form that when
:> Access starts is loaded and this form has VBA code attached to it.
[quoted text clipped - 12 lines]
:> Mike
:> m charney at dunlap hospital dot org

: I have a one line solution but I guess that's too few.

: Besides, 99 times out of 100, it's bad form and/or reflects poor design to
: be constantly deleting and creating a table, and I wouldn't want to
: propogate bad form or poor design.

: What's that, you just asked or a solution and not a lecture? Tant pis!

     Now that you've heard the advice of a master user of Access,
     here's something found by a 'fair' user of google:

        http://www.fontstuff.com/access/acctut16.htm

    gives the one-line of code for deleting a table. I'm sure Lyle
    can actually do the whole thing in one line, but *I* would need
    to add error-trapping code to handle the error if the table
    doesn't exist.
                      --thelma

                         
Mike Charney - 17 Apr 2006 14:26 GMT
> :> I have an Access data project. In this project I have a form that when
> :> Access starts is loaded and this form has VBA code attached to it.
[quoted text clipped - 32 lines]
>     doesn't exist.
>                       --thelma

Thanks Thelma.

I guess Lyle was to busy being an arrogant butt to help.
Tim Marshall - 17 Apr 2006 14:25 GMT
> Does the table exist, Yes = Delete it, No=Continue code execution.

Why don't you just simply run the equivalent of a delete query:

Delete * from tblimport

and do your coding based on an empty table?

Not sure how this is done exactly in ADO, but the DAO equivalent, is a
simple

CurrentDb.Execute "delete * from tblimport", dbFailOnError

As Lyle says, it's frankly kind of silly to be deleting and,
presumeably, creating tables in an app this way.  Replace your "create
table" type code with an append query.
Signature

Tim    http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto  "TIM-MAY!!" - Me

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.