Change criteria in Query

  • Thread starter Thread starter Dennis
  • Start date Start date
D

Dennis

Access 2003

What is the VBA code to change a criteria Filter in a Query?

For example, I have been attempting to:

In table "Utilities"
For Query "All to Date"
In Field "Amount"
Criteria "> 1,000"

If I had just one example, I could extrapolate to other Query Items. I just need a starting point.

Query.Filter = BuildCriteria("Amount", ?????, ">1000")
FilterOn

DAO.QueryDef is supposed to be read-only
would DAO.TableDef be better? I'm lost!

If there is a better way, I would appreciate at least some clues.



TIA Dennis
 
It sounds like you want a parameter...There's an example in on-line help,
check the Parameters property of the QueryDef object. Not everything can be
done with parameters, though, so you might need to fiddle with the SQL
property of the QueryDef.

Oh, and the QueryDef is an object. Some of it's properties are read-only,
but you can certainly create the object in code.


HTH

--
Rebecca Riordan, MVP

Designing Relational Database Systems
Microsoft SQL Server 2000 Programming Step by Step
Microsoft ADO.NET Step by Step

http://www.microsoft.com/mspress

Blessed are they who can laugh at themselves,
for they shall never cease to be amused...
 
Back
Top