Access 2010 filter a form using mulitiple combo boxes working together and independently

Wingfoot

New Member
Joined
Oct 10, 2014
Messages
37
Hi

Please could sombody help me with these 2 related queries:

1. I have a form which can be filtered by Name and Date using two combo boxes, the Date combo box filters based on the selection of the Name combo box. This is fine apart from if I just want to filter by date, in which case it won't let me. Please could someone let me know how to get these two combo box filters working both independently as well as together. See code below that I am using so they work together:

Code:
Private Sub Combo95_AfterUpdate()
If IsNull(Me.Combo95) Then
'Remove the filter
Me.Filter = vbNullString
Me.FilterOn = False
Else
Me.Filter = "[PO Type Name] = '" & Me.Combo87 & "' AND [Booking Date] = #" & Me.Combo95 & "#"
Me.FilterOn = True
End If
End Sub

2. This is a strange one - for some reason although my date filter works fine for some dates, it doesn't seem to work for others e.g. my date range is currently from 01/11/2014 - 30/11/2014. The filter works when I select 11/11/2014 or above but doesn't work for earlier dates in the range even though those dates are present in my table. Would anybody know why this would be and be able to help me?

Many thanks
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Hello Wingfoot,
1. Currently the combo boxes are not acting independently because you refer to them both in the Combo95 filter:
Me.Filter = "[PO Type Name] = '" & Me.Combo87 & "' AND [Booking Date] = #" & Me.Combo95 & "#"

Move the Combo87 filter criterion to that control. Then each should behave independently, and can act together by applying a filter to each.

2. Although there are records prior to 11/11/2014 your current filter means you also need to consider whatever is selected for PO Type Name. Are the prior records associated with a different PO Type Name to that currently selected?

With kind regards
 
Upvote 0
Hi Head Case

Thank you for your reply.

Regarding 2. - I've managed to solve that one by adding the following formatting to my code:

Code:
Format(Me.Combo95, "\#mm\/dd\/yyyy\#")

As far as 1. is concerned, I initially set the two combo boxes, as you suggested, up on separate controls (see below) which enabled them to be used separately but each time I tried to filter by date, having filtered by name ([PO Type Name]), the name filter was removed. Please could you tell me what I'm doing wrong?

Code:
Private Sub Combo95_AfterUpdate()
If IsNull(Me.Combo95) Then
Me.Filter = vbNullString
Me.FilterOn = False
Else
Me.Filter = "[Booking Date] = " & Format(Me.Combo95, "\#mm\/dd\/yyyy\#")
Me.FilterOn = True
End If
End Sub

Private Sub Combo87_AfterUpdate()
If IsNull(Me.Combo87) Then
Me.Filter = vbNullString
Me.FilterOn = False
Else
Me.Filter = "[PO Type Name] = '" & Me.Combo87 & "'"
Me.FilterOn = True
End If
End Sub

Many thanks for your help.
 
Upvote 0

Forum statistics

Threads
1,214,976
Messages
6,122,543
Members
449,089
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top