Hi Dave
I don't quite understand why your main form needs to be bound to the query.
In fact, I don't see the need for a main form/subform at all.
If I understand you correctly, you have one or more textboxes to filter the
subform by [Date Sold] and perhaps other fields, and that you have a
combobox to select a specific record. You want the available rows in the
combobox to reflect only the filtered rows in the form.
I suggest you ditch the main form and use your subform as your main form.
Add the selection combobox and the filtering textboxes to the header or
footer of the form. Create a save query "qrySelectRecord" (or whatever) as
the RowSource of your combobox. Make sure that any fields that are used for
filtering are included in the query, even if they are out to the right hand
side of the columns that are used for display in the combo box.
At the end of the SetFilter function, add this code:
If Me.FilterOn Then
cboSelectRecord.RowSource = _
"Select * from qrySelectRecord where " & Me.Filter
Else
cboSelectRecord.RowSource = "qrySelectRecord"
End If
This will apply the same filter to your combo box as has been applied to
your form.
I hope I've understood you correctly. Post back if you still have a
problem.
--
Good Luck
Graham Mandeno [Access MVP]
Auckland, New Zealand
User the SetFilter code I gave you to set the filter on the form
xsdaver via AccessMonster.com said:
Wow, thanks for the detailed response. I'm quite green at this and it
took
me a bit to figure out what you were doing. I got it all working, but it
does not quite do what I'm looking for. I'll try to provide a better
description of what I'm trying to do.
I have a form with a subform. The main form's purpose in life is to find
the
records to be displayed on the subform. Both forms are based on the same
query. The recordset can be the entire query result with no filters or,
hopefully, filtered results based on dates and other parameters. There
are
no linked fields between the main form and subform. I have a combo box on
the main form that shows several columns of the query results. When you
select a row in the combo box it does a findfirst on the recordset for the
subform. The findfirst is looking for a unique value for each record, so
it
finds the exact record you selected.
Ideally, the filters set up by the dates for [Date Sold] and other
parameters
would filter both the combo box and the subform. I don't see a way to
filter
the data for the combo box other than through the query. Even though the
filter set up by your code filters the records for the main form, the
combo
box still shows all records. Can the string generated by your code be
used
in a where portion of the Row Source query property?
I assume it is possible to apply the filter from the main form to the
subform if filters to the form end up being the way to go.
Dave