Openform to display filtered records by year

On form #1 I have a combobox that allows the user to select records from a year.  The actual date fields in the table are short date like 1/12/2016.  But the combo-box displays "2016" because of the format in the query like:

Year: Format([TargetResolutionDate],"yyyy")

But then using a command button under the combo-box I'm trying to open a 2nd form to display all the records that had a TargetResolutionDate in 2016.

I've tried this but it doesn't work:

DoCmd.OpenForm "frmProjectIssue", , , "[TargetResolutionDate] = #" & Format([cboProjectDate], "yyyy") & "#"

Can someone help?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rey Obrero (Capricorn1)Commented:

DoCmd.OpenForm "frmProjectIssue", , , "[TargetResolutionDate] = '" & Format([cboProjectDate], "yyyy") & "'"


DoCmd.OpenForm "frmProjectIssue", , , "[TargetResolutionDate] = " & Year([cboProjectDate])
SteveL13Author Commented:
Neither one worked.  Remember even though I'm formatting the combobox to only display the year part of the records there may be several records that have a date in 2016.

If it helps here is the SQL for the combo-box:

SELECT DISTINCT Format([TargetResolutionDate],"yyyy") AS [Year]
FROM tblProjectIssues;

Open in new window

Rey Obrero (Capricorn1)Commented:
how is data displayed in [TargetResolutionDate]?
is it like this 1/1/2016?

DoCmd.OpenForm "frmProjectIssue", , , "Year([TargetResolutionDate]) = " & me.cboProjectDate

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dale FyeOwner, Dev-Soln LLCCommented:
Dim strCriteria as string
strCriteria = "[TargetResolutionDate] >= #" & DateSerial(me.cboProjectDate, 1, 1) & "# AND " _
            & "[TargetResolutionDate] < #" & DateSerial(val(me.cboProjectDate) + 1, 1, 1) & "#"
debug.print strCriteria
DoCmd.OpenForm "frmProjectIssue", , , strCriteria

Open in new window

This will basically create a criteria string that looks like:
[TargetResolutionDate] >= #1/1/2016# AND [TargetResolutionDate] < #1/1/2017#

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.