dmarsh16946
Technical User
I can successfully use a fixed query to feed a function like this for a mail merge
MergeAllWord ("Select * FROM qryContactsSelected")
If the query takes data from unbound fields in a selector form, eg setting the criterion for a field called category to say
forms!frmSelect.cboSelectCategory
the function brings up an SQL error. I've run into this before and used a dodge to change the query to a make-table query first, then use the new table in the select statement.
It looks like the QueryDef function might more neatly avoid this dodge but I don't know how to set it up. I've seen other people using code that would translate into something like this
Dim qd as DAO.QueryDef
Set qd = db.QueryDefs("qryContactsSelected")
' Set parameter
qd.Parameters(0) = forms!frmSelect.cboSelectCategory
' Open recordset
rstData = qd.OpenRecordset
etc
but really not sure what would come next.
Any pointers gratefully received.