Best Way to Dynamically Alter the Select List of A Query

A

A. Smart

With respect to my earlier post, I am trying to find the best way to
dynamically alter the select list of a query.
Any suggestions!!
Cheers
 
J

Jeff Boyce

Ashley

Answered in your earlier post.

Another (BUT MUCH CLUNKIER) approach would be to build as many different
queries as you would need for any/all combinations of choices on your form.
Then, in code behind your form, values in fields would be tested to
determine which query to run. CLUNKY! INELLEGANT!

Regards

Jeff Boyce
<Access MVP>
 
O

oozyscab via AccessMonster.com

I do this all the time in code simply by altering the SQL of the querydef,
like this...

Function ModifyQuery(sQueryName As String, sSql As String) As Boolean
On Error GoTo Err_ModifyQuery

Dim dbModify As DAO.Database
Dim qdfModify As DAO.QueryDef

Set dbModify = CurrentDb
Set qdfModify = dbModify.QueryDefs(sQueryName)
qdfModify.sql = sSql

ModifyQuery = True

Set qdfModify = Nothing
Set dbModify = Nothing

Exit Function
Err_ModifyQuery:
ModifyQuery = False
Err.Raise Err.Number, Err.Source, Err.Description
End Function
 
Top