Results 1 to 8 of 8
  1. #1
    hawkins is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jun 2011
    Posts
    82

    Query to search for Certain Years


    I am creating a feeder status report and the feeders have static information and changing information depending on the year. I have a static table called Static, which has a list of the feeder names and static information about them. I also have a table called Yearly which holds information by the year and is referred to the Static table by the feeder name. I was wonidering how I could set up a query in the report to search for the current year value out of the Yearly table say I want the CalcGrwth (Column Name) value for a specific feeder name. I created the base report using the wizard so that the feeder name changes and I want to correspond that name to the year. Similar Id want the previous year as well. I have done this by using the report wizard but it is not in the format I would like. I am new to access so detailed explanations would be greatly appreciated. Thank you for your help and any suggestions are welcome!

  2. #2
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    What does the field that has the date information look like? If it is a full date then you can create your own field in the query for year and then have the criteria like this.

    First, the field in the query - so in the QBE grid you would have:

    CalcGrwthYear:Year([FieldWithDateInfoInIt])

    and the criteria for the current year would simply be:

    Year(Date())

    Then the criteria for the previous year

    Year(Date())-1

  3. #3
    hawkins is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jun 2011
    Posts
    82
    Thank you for the response, the year field is only the year, for example 2010, I tried to do CalcGrwthYear:Year([YearRecorded]) in a QBE field and then criteria I used Year(Now()) and Year(Date()) but I did not recieve any results even though there are years of 2011 in my table.

  4. #4
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    If the Year field is only the year then you wouldn't need to create a separate field and you could just use

    Year(Date())

    as the criteria on that field. But, if that Year field [YearRecorded] is text then you would have to use

    Cstr(Year(Date()))

    as the criteria.

  5. #5
    hawkins is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jun 2011
    Posts
    82
    Thank you, that worked perfect! I was also wondering how to make sure the query results only include the name given in the header of the report (sorted by name).

  6. #6
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Quote Originally Posted by hawkins View Post
    I was also wondering how to make sure the query results only include the name given in the header of the report (sorted by name).
    Not sure I understand what you're asking for. Please explain a bit more in detail what you are looking to do with that, how it currently works, etc.

  7. #7
    hawkins is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jun 2011
    Posts
    82
    I have attached a file of my database. I am just trying to 'screw' around on this one so I dont mess up my bigger one I have been working on. I am trying to create a page report for each of the feeder name. Each feeder has static and yearly information. The report now is organized by feeder name and I want to use the query to be able to get yearly data for each year so I can then organize it the way I would like it to look. As of right now, my query runs how I would like to but in the report it does not show any results as it did when I ran the query. Also I want the results to this query (when it is able to work) to be based upon the feeder name for that page.

  8. #8
    hawkins is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jun 2011
    Posts
    82
    thanks for the help, I finally figured it out by adding [Reports]![Static]![Name] to the criteria of the name.

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

Similar Threads

  1. Select changes in the years
    By acs_one in forum Queries
    Replies: 8
    Last Post: 11-27-2010, 05:26 PM
  2. Replies: 1
    Last Post: 11-12-2010, 01:16 AM
  3. Query Multiple years
    By sammer021486 in forum Queries
    Replies: 3
    Last Post: 10-21-2009, 02:13 PM
  4. query date that is five years older than today
    By cpsummer in forum Queries
    Replies: 2
    Last Post: 09-26-2007, 02:31 PM
  5. Replies: 1
    Last Post: 03-15-2007, 03:38 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