Sort by Month and Day

G

Guest

I have a report that list the Month and Day in seperate fields. Want to sort
by Month and then Day. For the month, I tried putting =Month([Month]) in the
sorting and grouping field but I get a "Data Type Mismatch in Criteria
Expression" error. Have the month field set up as a text. Why?
 
M

Marshall Barton

Supe said:
I have a report that list the Month and Day in seperate fields. Want to sort
by Month and then Day. For the month, I tried putting =Month([Month]) in the
sorting and grouping field but I get a "Data Type Mismatch in Criteria
Expression" error. Have the month field set up as a text. Why?


What is the text in those fields?

Don't you think the expression Month(Month) is confusing?
There is probably some situations where Access will be
confused by such a blatent disregard for reserved words.
You should not create names that are keywords in Access.
Because there are so many reserved words, a good practice is
to never create a name that is an ordinary word (instead of
using Month for the field name, use something more like
ProjectMonth).

I think your problem is that the Month function requires a
date type value, not a text string that might be a month
name or month number or your dog's name or ....
 
D

Duane Hookom

What are typical values in the month field? You should use a numeric field
that stores the month number (1 - 12). This would sort correctly.
If your [Month] field is numeric and you attempt to use the Month()
function, you will get either 12 (December) or 1 (January) since the Month()
function expects a full date expression as its argument, not a month value.
You should want to ever find the month of a month.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top