Hi,
I am new to access so this may be a simple question but I appreciate your help.
I am running a query to select tasks that have to be completed in a given month during a specific year. I want the users to be able to use a form I created to select the month and year and then have the query use the months and year from the form. I can get the query to select all the tasks based on the month or select all of the tasks based on the year, but it yields no results when I use an And statement to combine the two expressions. Here is what I have so far:
A query called [qryEventDates] that has all the tasks and their corresponding due dates. The due date field is called [EventDate] and is in date and time format.
A form called [Report by POC] that lets the user select the month and year. The form has a combo box for month called [ComboMonth_RBP] and a text box called [YearBox]
If I enter this expression in my query...
(DatePart("m",[qryEventDates]![EventDate])=[Forms]![Report by POC]![ComboMonth_RBP])
it selects all the tasks due by the month on the form. This makes sense.
If I enter this expression...
(DatePart("yyyy",[qryEventDates]![EventDate])=[Forms]![Report by POC]![YearBox])
it selects all the tasks due during the year specified on the form. This also makes sense.
However, if I enter this expression...
(DatePart("m",[qryEventDates]![EventDate])=[Forms]![Report by POC]![ComboMonth_RBP]) And (DatePart("yyyy",[qryEventDates]![EventDate])=[Forms]![Report by POC]![YearBox])
It selects nothing, even when there are tasks due in that given month and year.
Does anybody know what could be causing this? Should I be using a different approach? I appreciate any advice you can offer. Thanks for your time.