[AccessD] Multi-Select List Box problems

Stuart McLachlan stuart at lexacorp.com.pg
Mon Sep 6 09:48:18 CDT 2021

On 6 Sep 2021 at 9:43, Arthur Fuller wrote:

> That's a concrete example. I'll have to rewrite the query each time
> the process is run, which begs the, How can I access the Criterion
> part of a named query? this would really simplify matters. I could
> just refer to the Criteria part and substitute the current selection.

Demo of grabbing a SQL of a saved query and changing it:

Function TestQD()
Dim qd As QueryDef
Dim sSQL As String

'Get existing qryTest
Set qd = CurrentDb.QueryDefs("qryTest")
sSQL = qd.SQL
Debug.Print sSQL

' change the SQL
qd.SQL = "SELECT * from tblCustomers"

'Get it again to confirm it's changed
Set qd = CurrentDb.QueryDefs("qryTest")
Debug.Print qd.SQL

'Set it back to the original
qd.SQL = sSQL

'Make sure that it's back to original
Set qd = CurrentDb.QueryDefs("qryTest")
Debug.Print qd.SQL
Set qd = Nothing
End Function

More information about the AccessD mailing list