Building Query Criteria

  • Thread starter Thread starter R. BRADFORD THOMAS
  • Start date Start date
R

R. BRADFORD THOMAS

Good Afternoon,
I am using Windows 2000 and Access 2000.

How can I change the Criteria in a query from Visual Basic coding in a
Module??



Brad
 
You cannot change just the criteria.

Alternatives:
1. Create the entire SQL statement as a string, and handle it directly (e.g.
OpenRecordset, Execute, or assign to a RecordSource).

2. Reassign the SQL property of the QueryDef.

3. Declare parameters in the query, and assign just the parameters at
runtime.

#1 is generally the simplest, and avoids dependency on a saved query.

#2 is sometimes useful for setting the RecordSource of a subreport before
opening.

#3 is simple, but not as flexible (i.e. you do have to provide something for
the parameter).
 
Thank you Allen,

Brad


Allen Browne said:
You cannot change just the criteria.

Alternatives:
1. Create the entire SQL statement as a string, and handle it directly (e.g.
OpenRecordset, Execute, or assign to a RecordSource).

2. Reassign the SQL property of the QueryDef.

3. Declare parameters in the query, and assign just the parameters at
runtime.

#1 is generally the simplest, and avoids dependency on a saved query.

#2 is sometimes useful for setting the RecordSource of a subreport before
opening.

#3 is simple, but not as flexible (i.e. you do have to provide something for
the parameter).
 
Back
Top