Create querydef from recordsetclone

U

UpRider

I need to feed a subroutine a query name from a form. The subroutine prints
labels a line at a time to a dot matrix printer (no reportdef involved),
using parameters that identify the query and the number of labels to print.
How can I turn the form's recordsetclone (selecting the current record) into
a query? Currently I use the same query as the form recordsource and it
works fine, but I'd like to make it generic for any form and recordsource,
thus the recordsetclone idea.
Any attempts to diminish my ignorance are welcome and appreciated.

UpRider

'"""""Begin fragment, code is in form module
If MsgBox("Use Epson-500 dot matrix printer in label save mode?",
vbYesNo) = vbYes Then
DoCmd.SetWarnings False
'DoCmd.DeleteObject acQuery, "qtempQuery"
DoCmd.SetWarnings True
'below is recordsource of form and select criteria (Lastid is PK of
underlying table)
strSQL = "select * from qDBTCMmastAlpha where LastID =" & Chr$(39) &
Me.txtLASTID & Chr$(39)
Set qthisQuery = db.CreateQueryDef("qtempQuery", strSQL)
Call subPrintDotMatrixLabels("qtempQuery", NumLab)
Exit Function
End If
"""""End fragment
 
U

UpRider

Well, OK, thanks, I got that already. I'd like to be able to set the
recordsource to a common query name that I can pass to the subroutine from
ANY form without having to customize the code for the specific form.

UpRider
 
K

Ken Snell [MVP]

Perhaps it would help if you give a specific example... I'm not following
you here, as sending the form's RecordSource to a subroutine as an argument
is a generic thing to do:

Call MySubroutine(Me.RecordSource)

--

Ken Snell
<MS ACCESS MVP>
 
U

UpRider

Thanks, Ken. Simpler than I thought.

UpRider

Ken Snell said:
Perhaps it would help if you give a specific example... I'm not following
you here, as sending the form's RecordSource to a subroutine as an
argument is a generic thing to do:

Call MySubroutine(Me.RecordSource)
 
Top