Urgent - filter subform by form - option group

M

miss031

I have an unbound form with:
1 textbox, 6 option buttons and a command button.

It also contains an unbound subform. I would like to enter a value into the
text box, click one of the option group buttons, then click the command
button, and have the records of the subform filtered by that value.

I have tried several different approaches that have worked previously on
other forms of mine, and I have also tried a few procedures found on here,
but I cannot get it to work. I'm sure its just a "forest for the trees" kind
of thing, like a "." instead of a "!", but I am stumped, and on a deadline.

The subform record source is a query. "seller_number" is a text field, and
[subform_sale_masters] *is* the control name, not the control's source name.
The main form is called [sale_masters], and the text box used for input of
criteria is [txt_search_box]. The command button that fires the procedure is
cmd_search.

I have included the code for if the first option button is chosen. Please
review and help if you can. Thanks.

_____________________________

Private Sub cmd_search_Click()

Dim strWhere As String
Dim rs As DAO.Recordset
Dim frm As Form

If Me.frame_choose_criteria = 1 Then
If Not IsNull(Me.txt_search_box) Then
'Save before move.
If Me.Dirty Then
Me.Dirty = False
End If
'Search in the clone set.
Set frm = Me.subform_sale_masters.Form
strWhere = " Me.[subform_sale_masters].[seller_number] = """ &
Me.txt_search_box & """"
'Debug.Print strWhere
frm.Requery
Set rs = frm.RecordsetClone
rs.FindFirst strWhere
If Not rs.NoMatch Then
frm.Bookmark = rs.Bookmark
End If
End If
Set rs = Nothing

End If

_______________________________
 
J

John W. Vinson

It also contains an unbound subform.
The subform record source is a query.

Sorry... which is it?

The subform is either unbound, or it has a recordsource. It can't be both!

John W. Vinson [MVP]
 
M

miss031

Sorry! I meant it is not linked to the parent form, which is unbound. The
subform *is* bound to a query.
 

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

Similar Threads


Top