Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filtering in subform

Status
Not open for further replies.

cikul

Programmer
Aug 25, 2001
12
0
0
EU
I have a form with subform and I made a form which is switchboard with fields for searching.
How can I filter records both from main form and from subform to show data which I enter
in search fields on switchboard form. I managed to filter records in the main form record and
when i choose record from the combo box on switchboard form, the command button succesfully
opens the form with that record. But how can I then filter records in subform of that
same form?
For exmpl. record on main form shows owner of animal and subform shows all animals that are
property of that owner. I choose owner from switchboard and press command button for
opening the form "customers" and it shows me that owner and all his animals in subform.
I want to be able to choose owner from switchboard and enter aditional criteria for animals,
like, born on specific date or weight between...and etc. I could not done that because
it is subform that details are displayed in.
I used the following sintax for opening that form:

Dim stLinkCriteria As String

If Not IsNull([Customer]) Then
stLinkCriteria = "[Customer]=" & "'" & Me![Customer] & "'"
DoCmd.OpenForm "CUSTOMER", , , stLinkCriteria
End If

I can add aditional criteria on docmd.open but only related to fields on main form.
I think i can not add criteria that is related to subform and form. I can not add criteria in the command line
where I docmd.openform "Form" that is related to the field on subform and not to field on main form. For exmpl.

DoCmd.OpenForm "CUSTOMER", , , "[Customer]=" & "'" & Me![Customer] & "'" AND "Forms![Customer]![CustomerSubform].Form![Name] = 'Bobo'"

[Customer] is field on main form and [Name] is the field on Subform.
Or maybe it is possible?
I did'nt make it.

I tried to add procedure for filtering to the onLoad event of the subform and it works if you open that form like
standalone but it does not work when that form is subform...

Please help ASAP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top