Code to Modify Row Source

esskaykay

Registered User.
Local time
Today, 12:07
Joined
Mar 8, 2003
Messages
267
Is it possible to modify the Row Source control of combo box (called cmbWO) on a form. I want to change the filter for the field SYSTEM (to either SAN or STO). I see how you can change the Record Source of a form but not sure about a specific fields Row Source on the form.

Example-

Click Button-A:
SELECT DISTINCT [WO_Number] FROM [taction] where [system] = "SAN" order by [WO_NUMBER];

Click Button-B:
SELECT DISTINCT [WO_Number] FROM [taction] where [system] = "STO" order by [WO_NUMBER];


Then open the form accordingly with the specified Row Source.

Thanks,
SKK
 
It would have to be done with the form open:

Me.ComboName.RowSource = "SELECT..."
 
Excellent - will try.

Thanks for your time,
SKK
 
It would have to be done with the form open:

Me.ComboName.RowSource = "SELECT..."


You can actually do it any time the form is open. You just need to requery the control after the value has been changed in order to see the update. We do this on occasion when a combo box is allowed to display differing subsets of the whole dataset, based on the value entered in another field.
 
You can actually do it any time the form is open.

I must not have written that clearly enough. I meant simply that the form had to be open to set the source ("with the form open"). Perhaps you interpreted my answer as saying it had to be done in the form open event, which was not my intent.
 
I must not have written that clearly enough. I meant simply that the form had to be open to set the source ("with the form open"). Perhaps you interpreted my answer as saying it had to be done in the form open event, which was not my intent.

Sorry, that is exactly what I thought you meant, and I was just offering another POV
 
BTW, in my experience this is not necessary when you set the rowsource property:

You just need to requery the control after the value has been changed in order to see the update.
 
Just to throw out an alternative-

You also can use parameter query and just set the parameter without having to writing the entire SQL.
 

Users who are viewing this thread

Back
Top Bottom