Results 1 to 2 of 2
  1. #1
    Mattrob is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2013
    Posts
    1

    SELECT Records based on user input

    Hi All



    I have a set of data which contains fields 1 through 12 for months of the year and one field for the year with one row of data for each year and each customer. I am trying to produce a query to present 18 months worth of data per customer based on an input of current month and current year. EG Month 0 of the resulting data would be the current month, Month-1 would be last month and month+1 would be next from last year. I am thinking I just need to create 18 separate select queries and then a union query to bring the results together. Does anyone have any suggestions on an easier way?

    Terr CustName Year 1 2 3 4 5 6 7 8 9 10 11 12
    SIS CUSTOMER 1 2011 0 0 55.8 0 0 0 0 0 0 0 55.8 0
    SIS CUSTOMER 1 2012 0 0 0 0 90 0 0 0 0 0 0 0
    SIS CUSTOMER 1 2013 0 0 0 0 0 1170 0 0 0 0 -1170 0
    SIS Customer 2 2011 0 0 300 0 0 0 0 0 0 0 0 0
    SIS Customer 2 2012 0 0 0 14 0 0 126 0 0 0 0 0
    SIS Customer 2 2013 0 0 0 0 0 0 0 0 0 0 450 0

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You should normalize your table. The way you have it set up now is known as "Committing Spreadsheet".

    Your table structure should look like:

    Fields
    --------------------------
    Terr Text
    CustName
    DataYear (Year is a reserved word)
    DataMonth
    Reading


    Terr CustName DataYear DataMonth Reading
    SIS CUSTOMER 1 2011 1 0
    SIS CUSTOMER 1 2011 2 0
    SIS CUSTOMER 1 2011 3 55.8
    SIS CUSTOMER 1 2011 4 0
    SIS CUSTOMER 1 2011 5 0
    SIS CUSTOMER 1 2011 6 0
    SIS CUSTOMER 1 2011 7 0
    SIS CUSTOMER 1 2011 8 0
    SIS CUSTOMER 1 2011 9 0
    SIS CUSTOMER 1 2011 10 0
    SIS CUSTOMER 1 2011 11 55.8
    SIS CUSTOMER 1 2011 12 0
    SIS CUSTOMER 1 2012 1 0
    SIS CUSTOMER 1 2012 2 0
    SIS CUSTOMER 1 2012 3 0
    SIS CUSTOMER 1 2012 4 0
    SIS CUSTOMER 1 2012 5 90
    SIS CUSTOMER 1 2012 6 0
    SIS CUSTOMER 1 2012 7 0
    SIS CUSTOMER 1 2012 8 0
    SIS CUSTOMER 1 2012 9 0
    SIS CUSTOMER 1 2012 10 0
    SIS CUSTOMER 1 2012 11 0
    SIS CUSTOMER 1 2012 12 0
    SIS CUSTOMER 2 2011 1 0
    SIS CUSTOMER 2 2011 2 0
    SIS CUSTOMER 2 2011 3 300
    SIS CUSTOMER 2 2011 4 0
    SIS CUSTOMER 2 2011 5 0
    SIS CUSTOMER 2 2011 6 0
    SIS CUSTOMER 2 2011 7 0
    SIS CUSTOMER 2 2011 8 0
    SIS CUSTOMER 2 2011 9 0
    SIS CUSTOMER 2 2011 10 0
    SIS CUSTOMER 2 2011 11 0
    SIS CUSTOMER 2 2011 12 0

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

Similar Threads

  1. Criteria based on user input
    By Alsail77 in forum Queries
    Replies: 5
    Last Post: 08-16-2012, 02:19 PM
  2. How do you select a field based on user input?
    By technesurge in forum Queries
    Replies: 5
    Last Post: 06-20-2012, 02:04 PM
  3. Selecting records based on criteria from user input
    By shabbaranks in forum Programming
    Replies: 1
    Last Post: 01-04-2012, 09:06 AM
  4. display a list of values based on user input
    By karl1971 in forum Access
    Replies: 3
    Last Post: 12-06-2011, 09:19 AM
  5. Replies: 3
    Last Post: 08-25-2010, 09:03 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