Combo Box Selection Filters Results in Subform (1 Viewer)

chickenwings23

New member
Local time
Today, 01:04
Joined
Jun 3, 2022
Messages
21
Can a filter occur for combo box selection into subform
 
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 23:04
Joined
Oct 29, 2018
Messages
19,201
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
Yesterday, 23:04
Joined
Oct 29, 2018
Messages
19,201
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...
 

chickenwings23

New member
Local time
Today, 01:04
Joined
Jun 3, 2022
Messages
21
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, 14:04
Joined
May 7, 2009
Messages
16,875
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, 14:04
Joined
May 7, 2009
Messages
16,875
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: 63

Gasman

Enthusiastic Amateur
Local time
Today, 07:04
Joined
Sep 21, 2011
Messages
10,868
The master should be the combo?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 02:04
Joined
Feb 19, 2002
Messages
36,961
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.
 

chickenwings23

New member
Local time
Today, 01:04
Joined
Jun 3, 2022
Messages
21
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
Yesterday, 23:04
Joined
Oct 29, 2018
Messages
19,201
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