Results 1 to 6 of 6
  1. #1
    Evans2 is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    Jul 2014
    Location
    Seattle
    Posts
    27

    Query sorted by month and year

    Hi all,

    I've got a form based on a query that lists all product samples sent out to customers in ascending order by MM/DD/YY. I can see how this will become overwhelming quickly as many samples are sent out each day and users will have to scroll endlessly to find something.



    I'd like to organize all of the items by month and year.

    What I have now:

    8690 08/29/14 CRD
    8691 08/29/14 KMK
    8692 08/29/14 SHE
    8693 09/02/14 EBS
    8693 09/02/14 EBS
    8694 09/02/14 EBS

    What I would like:

    +August 2014
    8690 08/29/14 CRD
    8691 08/29/14 KMK
    8692 08/29/14 SHE

    +September 2014
    8693 09/02/14 EBS
    8693 09/02/14 EBS
    8694 09/02/14 EBS

    Is it possible to have all samples grouped by month and year where the users can just click on the month and have a list expand?
    Thank you,

    Evan
    Last edited by Evans2; 09-13-2014 at 10:42 AM.

  2. #2
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    I would use 2 combo's for this, one for the year and one for the month. If to be used on a form.
    Default Value for year;
    Year(Now())
    Default Value for month;
    Format(DateSerial(Year(Date()),Month(Date()),Day(D ate())),"mmmm ")
    If in a query;
    CurMonth: Format(DateSerial(Year(Date()),Month(Date()),Day(D ate())),"mmmm ")
    HTH

  3. #3
    Evans2 is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    Jul 2014
    Location
    Seattle
    Posts
    27
    Thanks burrina,

    I'm very new to SQL. Could you tell me where I might insert the code you mentioned above? I haven't been able to get it to work.

    Here is the SQL for the query:

    SELECT OutboundSamplingT.SO, OutboundSamplingT.DateofEntry, OutboundSamplingT.RequestedBy, OutboundSamplingT.PackedBy, OutboundSamplingT.MailedBy, OutboundSamplingT.SentDate, OutboundSamplingT.Customer, SampleEntryBoxT.Origin, SampleEntryBoxT.Type, SampleEntryBoxT.SampleRequested
    FROM OutboundSamplingT INNER JOIN SampleEntryBoxT ON OutboundSamplingT.[SO] = SampleEntryBoxT.[SO Number]
    WHERE (((OutboundSamplingT.SentDate) Is Not Null));

    Much appreciated.

    Evan Stockdale

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Controls used to input filter criteria must be UNBOUND. As burrina suggested, use comboboxes - cbxYear and cbxMonth.

    Filter options:

    1. dynamic parameterized query (I never use this method)
    WHERE OutboundSamplingT.SentDate Is Not Null AND Year([date field])=Forms!formname!cbxYear AND Month([date field])=Forms!formname!cbxMonth

    2. I prefer VBA code builds filter string http://allenbrowne.com/ser-62code.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Evans2 is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    Jul 2014
    Location
    Seattle
    Posts
    27
    Thanks for the reply June7,

    I'm trying out Filter option #1 first. Would it be possible to get some help with the SQL syntax? I'm getting an error message so I'm sure something is out of place.
    Click image for larger version. 

Name:	SQL Syntax Error.jpg 
Views:	8 
Size:	117.1 KB 
ID:	18122

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Get rid of the comma in front of AND.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Yet another Month Year query question
    By bimcompu in forum Queries
    Replies: 3
    Last Post: 01-07-2014, 02:08 PM
  2. Current Month/Year Query
    By Roadbeer in forum Queries
    Replies: 3
    Last Post: 06-17-2013, 01:20 PM
  3. Replies: 4
    Last Post: 05-26-2013, 03:28 PM
  4. Month and Day only not Year to create query
    By ssalem in forum Queries
    Replies: 3
    Last Post: 02-28-2013, 02:37 PM
  5. Query / report per month and year
    By ripper in forum Queries
    Replies: 2
    Last Post: 10-24-2011, 07:51 AM

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