Avatar of matthewlorin7
matthewlorin7 asked on

Filtering Continuous Subform From Combobox

I am trying to filter a continuous view subform from a combobox.  Should be easy enough, but I can't make it work.  This is the code I have:

Private Sub Combo25_AfterUpdate()
   DoCmd.ApplyFilter , "Me.txtStatus = '" & Me.Combo25 & "'"
End Sub

I get no movement on the subform.  I can apply similar language to the main form to filter by last name:

Private Sub Combo227_AfterUpdate()
   DoCmd.ApplyFilter , "LastName = '" & Me.Combo227 & "'"
End Sub

This works successfully.  Any ideas why the subform filter is not working?  The record sources are different; this shouldn't matter, right?  The "allow filters" is set to "on" on the subform.  Thanks for any help.
Visual Basic ClassicMicrosoft Access

Avatar of undefined
Last Comment
matthewlorin7

8/22/2022 - Mon
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)



Try this:


Private Sub Combo25_AfterUpdate()
   Me.Filter = "[Status] = " Chr(34) & Me.Combo25 & Chr(34)
   Me.FilterOn = True
End Sub
Rey Obrero (Capricorn1)

is the combobox in the main form or subform?

if in the main form

Private Sub Combo25_AfterUpdate()
   me.subformName.form.filter="[status]= '" & Me.Combo25 & "'"
   me.subformName.form.filteron=true

End Sub
ASKER
matthewlorin7

DatabaseMX:  Thanks for the quick reply.  I plugged it in, but it did not work (syntax error).  I thought maybe [Status] should be [txtStatus], but that did not work either.  I'm really stumped on this one.  Seems like it should be easy.  Thanks again for the help, I really appreciate it.
Your help has saved me hundreds of hours of internet surfing.
fblack61
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)

"maybe [Status] should be [txtStatus],"

No ... you have to refer to a Field in the underlying table or query, not a control on the form.  Then, you are setting the field to a value from a control - in this case, the combo box.

Where is this combo box located?  What is the Bound column of the combo box?

mx
ASKER
matthewlorin7

Capricorn:  Thanks also for the quick reply.  The combobox is in header of the subform.  I'm trying to filter the status of my reports (listed in continuous view) from the combobox.  
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)

What is the Control Source for txtStatus?

mx
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
matthewlorin7

DatabaseMX:  The Control Source of txt Status is, as you accurately surmised earlier, "Status" from the query I have feeding my subform.  On a side note, I am recieving the error message "Expected: end of statement" on the main line of the code (Me.Filter = "[Status] = " Chr(34) & Me.Combo25 & Chr(34)).  The first "Chr(34)" is being highlighted.

SOLUTION
Rey Obrero (Capricorn1)

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER CERTIFIED SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)

Sorry ... try this:


Private Sub Combo25_AfterUpdate()
   Me.Filter = "[Status] = " & Chr(34) & Me.Combo25 & Chr(34)
   Me.FilterOn = True
End Sub
ASKER
matthewlorin7

That was it.  Thanks so much!!!
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)

What was it ?

mx
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)

How were you meaning to split the points here?

mx
ASKER
matthewlorin7

DatabaseMX:  That's not how I meant to split the points.  I meant to give you 300 and Capricorn 200; I obviously applied one set to the wrong user.  If you know how I can retract the points, I'll divide them accordingly.  Alternatively, I can open the same question again, have you answer it, and give you your share.  Sorry about that.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)

" If you know how I can retract the points, I'll divide them accordingly. "

Click the badly labeled 'Report Abuse' (it's not abuse here) and Community Services will be able to help you.

thx.mx
Rey Obrero (Capricorn1)

matthewlorin7,
you can give the points to MX.

my post post was just a slight correction...
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)

Really, a split is in order because of this post:

http:#a21633813

mx
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
ASKER
matthewlorin7

Thanks.  Points forthcoming.