Macro - Condition Test to determine if a table exists

R

rmhindley

In a Macro, in a row running a DeleteObject action, is there a function, like
DCount, that lets you test to see if a table exists so that the Macro knows
if the step should get run? When the table exists, using the statement
DCount("Field1","Table1") in the condition column will work, however, if the
table does not exist the Macro gave no response message or anything. It
simply stops. I hope to be able to use a function like DCount in the
condition column of the row without having to create a custom module. Any
thoughts or recommendations?


If a module is needed, what is the exact code I would need to call a module
(i.e. TableExists("MyTableName") that lets me pass the table name to it so it
can respond true or false. I am a bit rusty on my visual basic coding. It
has been a few years.

Mike
 
W

Wayne-I-M

You would be better doing this with a small bit of code rather than a macro

eg.
You can use a macro dcount then use "stop Macro"
This will count the records in a table to see if it is 0

Condidtion
DCount("*","SomeTableName") = 0

Action
StopMacro


But if you use a simple public function like this "before" the macro it will
be much better

Public Function SomeName(strTable As String) As Boolean
Dim strTableName As String
On Error Resume Next
strTableName = CurrentDb.TableDefs(strTable).Name
TableExists = Not (strTableName = "")
End Function


Good Luck - Hope this helps
 

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