Re: Confirming a table exists before deleting it

From: chris ciotti (chris.ciotti_at_gmail.com)
Date: 01/29/05


Date: Sat, 29 Jan 2005 11:26:22 -0500

On Sat, 29 Jan 2005 10:29:07 -0500, Gene wrote
(in article <7A221942-3CDD-450C-AFE3-05F023721A5C@microsoft.com>):

> I use a form to create a table called tblImport. If the table already
> exists
> (from previously running the form), I use the DoCmd.DeleteObject acTable to
> delete it. If the table does NOT already exist, I get an error message when
> the DoCmd is executed. Is there any command that can check if a table
> "exists", and then I can skip the delete if it does not.

Hi Gene -

Access keeps a hidden table of objects (it's one of the MSys* tables) which
you can query. I can't recall the name but if you unhide the system tables
(via Tools -> Options; this might vary by Access version) and have a look you
can wrap a call to DCount in a function. If it returns 1 then the table
exists. I've done this before and it worked but I don't have the code handy
and am relying on memory (which is fragile on Sat morning :-)

I don't know if this is better or worse than looping through the Tabledefs.
Good luck in any event.

--chris



Relevant Pages

  • Re: Problem with QueryDefs in VBA
    ... that, under those conditions, selecting via the "Select All" on the import ... dialog does not copy the MSys... ... When you imported all the objects into the new database, ... You said you got a message due to another query... ...
    (microsoft.public.access.formscoding)
  • Re: Automatic Decimals I dont want
    ... and it has 6 digits from the table Recall, heres what I have for the query: ... The format is set to fixed with 0 decimals for the combo box, the query, and the source table. ... named sku, then perhaps the following would work? ...
    (microsoft.public.access.forms)
  • Re: Automatic Decimals I dont want
    ... "RoyVidar" wrote: ... FROM Recall ... decimals for the combo box, the query, and the source table. ... I select one of the numbers, the decimals dissapear. ...
    (microsoft.public.access.forms)
  • Re: Great SWT Program
    ... I seem to recall that not actually working so well. ... But if one wants the previous query, ... some of those tools anyway) by pressing the up arrow. ...
    (comp.lang.java.programmer)
  • Re: Access Query - INSTR function?
    ... As I recall you can't use the VBA constants in a query. ... You will need to replace vbTextCompare with 1 in the expression. ...
    (microsoft.public.access.gettingstarted)

Quantcast