CreateQueryDef Method (Professional Edition Only)
See Also Example
Description
Creates a new QueryDef
Syntax
Set querydef = database.CreateQueryDef(name [, sqltext ])
Remarks
The CreateQueryDef method uses these parts:
Part Description
querydef Object variable for the QueryDef object you want to create.
database Object variable identifying an open database that will store the new QueryDef.
name String expression that is the name of the new QueryDef which is saved in the database itself. You use this name with the OpenQueryDef and DeleteQueryDef methods.
sqltext String expression (a valid SQL statement) defining the QueryDef. If you omit this argument, you must define the QueryDef by setting its SQL property before using it.
You can use QueryDef objects to find and return records in the CreateDynaset and CreateSnapshot methods.
QueryDefs are listed in the TableDefs collection of a Database. To test if a member of the TableDefs collection is really a QueryDef, examine the Attributes property of a member of the TableDefs collection.
To open a QueryDef for changes, use the OpenQueryDef method. The QueryDef is automatically saved when you create or change it, even if it wasn't defined by sqltext.
To execute a QueryDef that performs an action, such as update, delete, or insert, use the Execute method. If you attempt to use a QueryDef that has not yet been defined by sqltext or the SQL property setting, an error occurs.
To delete an existing QueryDef, use the DeleteQueryDef method.