Been some time since I've done any real Access work and it's scary how much I've forgotten.
Anyway, want a simple query that returns results for a specific month (via combo box on separate form, format = dd/mm/yyyy, with the first of the month).
Records can have any 'day' number, but must be included.
What's the simplest method / syntax please?
Query criteria is a month
-
- Administrator
- Posts: 78629
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Query criteria is a month
One way to do it:
Add two calculated columns to the query design grid:
Y: Year([DateField])
and
M: Month([DateField])
where DateField is the name of the date field you want to filter on.
Clear the Show check box for these columns.
Set the Criteria row for the Y column to
Year([Forms]![NameOfForm]![NameOfComboBox])
and that for the M column to
Month([Forms]![NameOfForm]![NameOfComboBox])
substituting the name of the form and combo box, of course.
Add two calculated columns to the query design grid:
Y: Year([DateField])
and
M: Month([DateField])
where DateField is the name of the date field you want to filter on.
Clear the Show check box for these columns.
Set the Criteria row for the Y column to
Year([Forms]![NameOfForm]![NameOfComboBox])
and that for the M column to
Month([Forms]![NameOfForm]![NameOfComboBox])
substituting the name of the form and combo box, of course.
Best wishes,
Hans
Hans
-
- 5StarLounger
- Posts: 736
- Joined: 18 Mar 2010, 11:05
Re: Query criteria is a month
So simple.
Will give it a go in a bit
Cheers
Will give it a go in a bit
Cheers
-
- 5StarLounger
- Posts: 736
- Joined: 18 Mar 2010, 11:05
Re: Query criteria is a month
Works great.
I did miss out that this is a 'totals' query and needs to be grouped / summed.
Where there are multiple records in the month, I still get separate unique results.
Would I need to do a secondary 'totals' query to achieve this?
I did miss out that this is a 'totals' query and needs to be grouped / summed.
Where there are multiple records in the month, I still get separate unique results.
Would I need to do a secondary 'totals' query to achieve this?
-
- Administrator
- Posts: 78629
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- 5StarLounger
- Posts: 736
- Joined: 18 Mar 2010, 11:05
Re: Query criteria is a month
Doh!
Thank you
Thank you