qrydef

  • Thread starter Thread starter Bill H.
  • Start date Start date
B

Bill H.

Trying to set a parameter query for use in a combo box when the form
opens/loads

dim db as database, qdf as querydef
Set qdf = db.QueryDefs("Qry_Workshop")
qdf.Parameters("mWorkShop") = "A"

The combo box has the query "Qry_Workshop" as the rowsource

But when I select the combo box, up pops a window asking for the parameter!

Thx.
 
I don't believe it's possible to set parameters for rowsource queries like
that.

What you could do is base the query on a field on the form (it can be
hidden). Don't set the RowSource for the combo box: wait until the form
opens, and the field is populated, and then set the RowSource in code.
 
But it would be so much nicer if you could set the parameter query
that way.

Bummer.

From memory, don't the listboxes and combos in current versions have
..Recordset properties, that you can connect the querydef to?

private sub myForm_Load(Cancel as Integer)

set qdf = QueryDefs("Whatever")
qdf.parameters("A") = "Whatever Else"
set myComboBox.Recordset = qdf.OpenRecordset(dbOpenSnapshot)


I have to confess that in this situation I just create the SQL on the fly
and stick it into the rowSource property.

All the best


Tim F
 
Back
Top