This Access tutorial explains how to create Query in Access VBA using CreateQueryDef Method.
You may also want to read:
Change Query criteria
Access VBA create Query
Sometimes we don't want to create Query in Query Design View, because you may create a Query with criteria depending on a variable. To create Query in Access VBA, you can directly write a SQL statement in Access VBA, and then create a Query using the SQL statement with CreateQueryDef Method.
Syntax of CreateQueryDef
expres...
Read More