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
Today, 08:26
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, 15:26
Joined
May 23, 2011
Messages
4,717
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
Today, 08:26
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
Today, 08:26
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, 15:26
Joined
May 23, 2011
Messages
4,717
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, 15:26
Joined
Sep 21, 2011
Messages
14,056
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

Member
Local time
Today, 17:26
Joined
May 24, 2020
Messages
35
I thought Format([Order_date],"YYYY") instead of Year([Order_Date])
 

Users who are viewing this thread

Top Bottom