Search notes:

DAO Object Model: QueryDef

Check if a particular queryDef is already opened:
if sysCmd(acSysCmdGetObjectState, acQuery, "queryName") = acObjStateOpen then
  …
end if
Close an opened queryDef:
doCmd.close acQuery, "queryName"
Delete a queryDef (queryDef must be closed):
currentDB().queryDefs.delete("queryName")

execute

queryDef.execute executes the SQL statement that is associated with the queryDef. The number of affected records is returned by its recordsAffected property.
The execute method of queryDef executes the SQL statement that is associated with the respective queryDef object.
IMHO, execute should always be used together with the dbFailOnError option.

See also

Access Object Model

Index