Solved Filter subform (1 Viewer)

Araml

New member
Local time
Today, 00:58
Joined
May 4, 2020
Messages
22
Hi.
I want to have a subform with all the records of a table and a few combo boxes that filter the records shown in the subform. I would like to be able to filter with one or more combo boxes.

For example,
I have a table with attributes A, B and C, 2 combo boxes where I can choose records from B and C and a subform that displays every record on the table. I want to be able to choose a record on one or the two combo boxes and have the subform show only the records that abide by the combo boxes.

Thank you for your help.
 

Araml

New member
Local time
Today, 00:58
Joined
May 4, 2020
Messages
22
Thanks a lot.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 00:58
Joined
Jul 9, 2003
Messages
16,280
I provide a Search Form which is very easy to setup and use, (I've SET IT UP it in 4 Minutes!)

Search Form In 4 Minutes - Nifty Access



The Nifty Search Form is actually designed to use text boxes, not combo boxes but I have used it with combo boxes on occasion. Have a look at it on my website here:-


If you needed some help setting it up with combo boxes then I'm available.

Get the "Nifty Search Form" ifor free. Contact Uncle Gizmo for Details

https://gum.co/NiftySearchForm
 
Last edited:

Araml

New member
Local time
Today, 00:58
Joined
May 4, 2020
Messages
22

I tried using this method but with a subform instead of a section, however it isn't working, I believe the error might be in the Me.Filter = strWhere.

If lngLen <= 0 Then 'Nah: there was nothing in the string.
MsgBox "No criteria", vbInformation, "Nothing to do."
Else 'Yep: there is something there, so remove the " AND " at the end.
strWhere = Left$(strWhere, lngLen)
'For debugging, remove the leading quote on the next line. Prints to Immediate Window (Ctrl+G).
'Debug.Print strWhere

'Finally, apply the string as the form's Filter.
Me.Filter = strWhere
Me.FilterOn = True

Thanks for the help.
 

June7

AWF VIP
Local time
Yesterday, 15:58
Joined
Mar 9, 2014
Messages
5,470
Me qualifier refers to form code is behind. If code is behind main form then must be modified to reference subform.

Me.subformcontainername.Form.Filter = strWhere
Me.subformcontainername.Form.FilterOn = True
 

Araml

New member
Local time
Today, 00:58
Joined
May 4, 2020
Messages
22
Still not working, but I think I found the problem.
The combo boxes are based on a query that automatically add the primary key, so instead of adding (for example) John and Michael to strWhere I think it's adding 2 and 4 (the name ID).
Does this seem right to you, and if yes do you have any idea on how to solve this?
 

June7

AWF VIP
Local time
Yesterday, 15:58
Joined
Mar 9, 2014
Messages
5,470
So use primary/foreign key fields in search.
 

Users who are viewing this thread

Top Bottom