Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    nkuebelbeck is offline Advanced Beginner
    Windows 7 Access 97
    Join Date
    Mar 2010
    Posts
    91

    by year by month


    I have a date field that i would like to sort the record by. I want to sort by the year of that date and then by month of that year.

    Any help would be much appreciated.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Does simply sorting on that date field not produce the desired result? If not, then in the query underlying the report, add two calculated fields:

    YearSort: Year(YourDateField)
    MonthSort: Month(YourDateField)

    and sort on those two.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    nkuebelbeck is offline Advanced Beginner
    Windows 7 Access 97
    Join Date
    Mar 2010
    Posts
    91

    Ha

    I got this short after I posted. sometimes it just helps to spell it out. Do you know how i convert the month # to a string(so 3=March)

    maybe format([monthsort],"mmmm") ?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    The Format() function, yes.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    nkuebelbeck is offline Advanced Beginner
    Windows 7 Access 97
    Join Date
    Mar 2010
    Posts
    91

    noobish

    I used =Format([MonthSort],"mmmm") on the form control and i get #error

    Should I format in the query?

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    It should work in either, as long as that field is part of the form's source.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    nkuebelbeck is offline Advanced Beginner
    Windows 7 Access 97
    Join Date
    Mar 2010
    Posts
    91

    hmmmmm...

    It would not work in the form control. I did have it as the control source...

    MonthSort: Format([Entry Date],"mmmm")

    That did the trick in the query.

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    As long as you realize you can no longer use that field for sorting.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    nkuebelbeck is offline Advanced Beginner
    Windows 7 Access 97
    Join Date
    Mar 2010
    Posts
    91

    just realized that



    back to the drawing board

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Leave it as a number in the query, and add a textbox with the format function on the report.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    nkuebelbeck is offline Advanced Beginner
    Windows 7 Access 97
    Join Date
    Mar 2010
    Posts
    91
    I have this in the text box

    =Format([MonthSort],"mmmm")

    The text box is in the group header, now it shows up as january every time.....

  12. #12
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Can you post the db itself?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  13. #13
    nkuebelbeck is offline Advanced Beginner
    Windows 7 Access 97
    Join Date
    Mar 2010
    Posts
    91

    no

    sry, its too large

  14. #14
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    What happens if you put in a textbox bound to the MonthSort in the same section? Is it correct?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  15. #15
    nkuebelbeck is offline Advanced Beginner
    Windows 7 Access 97
    Join Date
    Mar 2010
    Posts
    91

    we think a like

    Did that. The one bound to the query is correct.

    see attached

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. month function..
    By thewabit in forum Programming
    Replies: 13
    Last Post: 04-19-2010, 10:01 PM
  2. Replies: 3
    Last Post: 12-23-2009, 08:50 AM
  3. Simple Report by Month
    By leejqs in forum Reports
    Replies: 3
    Last Post: 07-15-2009, 09:24 AM
  4. SQL Query by day to end of month
    By tcasey in forum Queries
    Replies: 0
    Last Post: 10-07-2008, 09:55 PM
  5. Total no of days in a month
    By wasim_sono in forum Forms
    Replies: 4
    Last Post: 10-15-2006, 01:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums