Combo Box Selection Filters Results in Subform (1 Viewer)

Local time
Today, 05:54
Joined
Jun 3, 2022
Messages
38
Can a filter occur for combo box selection into subform
 
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Today, 03:54
Joined
Oct 29, 2018
Messages
21,357
Hi. Yes, that should be possible. Is this requirement in addition to using the Linked Master and Child Fields?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 03:54
Joined
Oct 29, 2018
Messages
21,357
Master and Child Fields have been removed from the forms so there's no linking. (I was given this database to fix up)
Why were they removed? Just curious...
 
Local time
Today, 05:54
Joined
Jun 3, 2022
Messages
38
Why were they removed? Just curious...
As I spoke to my work colleague this morning, she stated that when the Master and Child Fields were linked the data was not displaying down below in the subform so she removed the "linking" and once the MainForm was filled out at the top, the subform down below populated the data.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 18:54
Joined
May 7, 2009
Messages
19,169
create first a Query for your table that you use in your Subform, eg:

(qrySubData)
select * from yourSubFormTableName where BrNumber = IIF(IsNull([Forms]![frmEstimateBt]![cboBrNumber]), [BrNumber], [Forms]![frmEstimateBt]![cboBrNumber])

In design view of your form, use the Query (qrySubData) as the RowSource of your Subform.
add code to the AfterUpdate Event of cboBrNumber combobox:

Private Sub cboBrNumber_AfterUpdate()
Me!subfrmEstimateBr.Requery
End Sub
 
Last edited:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 18:54
Joined
May 7, 2009
Messages
19,169
see this demo.
this is using the technique in post#7.
the data may not be the same with what you have
but the idea is the same.
 

Attachments

  • Branch.accdb
    704 KB · Views: 151

Gasman

Enthusiastic Amateur
Local time
Today, 10:54
Joined
Sep 21, 2011
Messages
14,038
The master should be the combo?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 06:54
Joined
Feb 19, 2002
Messages
42,970
Leave the Master/child links because you need them to restrict the search to only the children of the parent record.

Then change the RecordSource query of the subform to include a Where clause that references the UNBOUND combo on the main form.

Select ...
From ...
Where SomeField = Forms!MyMainForm!cboFilter OR Forms!MyMainForm!cboSearch Is Null

In the Click event of the combo, requery the subform:
Me.SubformControlName.Form.Requery

I think that Filters do not work on subforms.
 
Local time
Today, 05:54
Joined
Jun 3, 2022
Messages
38
Was able to figure this out by Linking the Master and Child Fields together, it worked! Thanks for the help on this.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 03:54
Joined
Oct 29, 2018
Messages
21,357
Was able to figure this out by Linking the Master and Child Fields together, it worked! Thanks for the help on this.
Hi. Congratulations! Glad to hear you got it sorted out. Good luck with your project.
 

Users who are viewing this thread

Top Bottom