check whether a table exists before running a macro (1 Viewer)

chthomas

Registered User.
Local time
Today, 20:40
Joined
Feb 8, 2000
Messages
32
Hi,

Could any one tell me how to check whether a table exists before running a macro? ie if the table exists don't run the macro else run the macro.

Regards,

Charley
 

Travis

Registered User.
Local time
Today, 12:40
Joined
Dec 17, 1999
Messages
1,332
Use this code

on error resume next
dim lCount as Long
dim stTable as String
stTable = "tblOLE"
lcount = currentdb.TableDefs(stTable).RecordCount
if err.Number = 3265 then
Msgbox "Table does not exist"
else
Msgbox "Table exists"
end if
 

Users who are viewing this thread

Top Bottom