Solved how to filter a subform using a combo box to select year on main form but filter a date field on a subform (1 Viewer)

sspreyer

Registered User.
Local time
Yesterday, 22:04
Joined
Nov 18, 2013
Messages
251
Hi ,
here what i've try but getting an error.
order date field on my subform is in format dd/mm/yyyy and my combo box on my main form only holds years in yyyy hoping to filter Order_date field on the subform via year. see below what i tried. guessing i need to change the Order_date field format to YYYY then apply the filter??

Code:
[Forms]![MonthlySpendCal]![CVorderQRYsubform].Form.Filter = "[Order_Date] = Format([Order_Date], "yyyy") = '" & Me.YearFormcbo & "  '"

thanks in advance

shane
 

bob fitz

AWF VIP
Local time
Today, 06:04
Joined
May 23, 2011
Messages
4,160
Try:
Code:
Me.[CVorderQRYsubform].Form.Filter = Year([Order_Date]) = '" & Me.YearFormcbo & "'"
Me.[CVorderQRYsubform].Form.FilterOn = True
in the AfterUpdate event of the combo box

EDIT:
Just noticed that you're in Stanford-Le-Hope. Just a "stones throw" away from me in Basildon :)
 
Last edited:

sspreyer

Registered User.
Local time
Yesterday, 22:04
Joined
Nov 18, 2013
Messages
251
Try:
Code:
Me.[CVorderQRYsubform].Form.Filter = Year([Order_Date]) = '" & Me.YearFormcbo & "'"
Me.[CVorderQRYsubform].Form.FilterOn = True
in the AfterUpdate event of the combo box

EDIT:
Just noticed that you're in Stanford-Le-Hope. Just a "stones throw" away from me in Basildon :)
Hi Bob

Code:
Me.[CVorderQRYsubform].Form.Filter = Year([Order_Date]) = '" & Me.YearFormcbo & "'"

I'm getting an error guessing quotes wrong?



Yeah not far at tall :) small world
 

sspreyer

Registered User.
Local time
Yesterday, 22:04
Joined
Nov 18, 2013
Messages
251
Solved it Thanks for the Help
Code:
[Forms]![MonthlySpendCal]![CVorderQRYsubform].Form.Filter = "Year([Order_Date]) = '" & Me.YearFormTXT & "'"

thanks
 

bob fitz

AWF VIP
Local time
Today, 06:04
Joined
May 23, 2011
Messages
4,160
Solved it Thanks for the Help
Code:
[Forms]![MonthlySpendCal]![CVorderQRYsubform].Form.Filter = "Year([Order_Date]) = '" & Me.YearFormTXT & "'"

thanks
You're welcome. Glad to help if I can :)
 

Gasman

Enthusiastic Amateur
Local time
Today, 06:04
Joined
Sep 21, 2011
Messages
7,451
Solved it Thanks for the Help
Code:
[Forms]![MonthlySpendCal]![CVorderQRYsubform].Form.Filter = "Year([Order_Date]) = '" & Me.YearFormTXT & "'"

thanks
I would not have thought that you would need single quotes for a year value?
 

IbrBadri

New member
Local time
Today, 08:04
Joined
May 24, 2020
Messages
28
I thought Format([Order_date],"YYYY") instead of Year([Order_Date])
 

Users who are viewing this thread

Top Bottom