Full Version: Filter Section With Check Box
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
KRoth472
Hello UA,

I wish to filter a sub-form column to only show purchase orders that are open or all purchase orders (open or closed) by selecting a checkbox on the main form. I see from the database examples that are out there at MSDN how to do this with a macro expression but I would like to do this with VBA since I am not to confident with my macro expression design yet.
Any links or ideas would be great. I have done some extensive searching and have not found the coding structure required to do this yet. Thanks

KR
theDBguy
Hi KR,

Check out the Filter property. You might end up with something like:

If Me.Checkbox = True Then
Me.Filter = "FieldName='open'"
Else
Me.Filter = "FieldName='closed'"
End If
Me.FilterOn = True

Hope that helps...
danishani
You can try this, by using the Filter() option of the Subform;

In the OnClick Event of the Checkbox;

Dim chkPurchased As String

If Me.Check1.Value = True Then
chkPurchased = "[Purchased]='Open'"
[Form_YourSubFormName].Filter = chkPurchased
[Form_YourSubFormName].FilterOn = True
Else
[Form_YourSubFormName].FilterOn = False
End If


HTH,
Daniel
KRoth472
Guys thanks for the info. That was exactly what I was looking for!

~KR
danishani
Glad to help! smile.gif

Cheers, cheers.gif

Daniel
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.