qrydef

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.
 
D

Douglas J. Steele

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.
 
B

Bill H.

But it would be so much nicer if you could set the parameter query that way.

Bummer.
 
T

Tim Ferguson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top