Can application.runcommand run in Access 2002

M

Matt

I have the following code that is being ignored/skipped when running a on a
machine with Access 2002:

Application.Echo False
DoCmd.OpenTable "DataTemplate"
Application.RunCommand acCmdSelectAllRecords
Application.RunCommand acCmdDelete
Application.RunCommand acCmdClose
Application.Echo True

I'm guessing that Access 2002's libraries don't have these commands available.

Thanks,

Matt
 
J

Joan Wild

DoCmd.RunCommand should work, but an easier way to delete all records (do
you really want to do that?) is to run a delete query...

CurrentDb.Execute "DELETE DataTemplate.* FROM DataTemplate;"
 
V

Van T. Dinh

RunCommand is a Method of the DoCmd Object and not a Method of the
Application Object. In addition, DoCmd is a Property of the Application
Object. Thus, if you want, you can use:

Application.DoCmd.RunCommand ...

but in Access VBA, the DoCmd is a "global" Property so you don't even need
to use the Application Object and simply use:

DoCmd.RunCommand ...

But for deleting all Records in a Table, Joan's method is the most
efficient.
 
Top