Results 1 to 7 of 7
  1. #1
    sarathicse is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2013
    Location
    Chennai, India
    Posts
    3

    How to form a query for my need

    Guys,

    I have a table as shown below

    Click image for larger version. 

Name:	temp.jpg 
Views:	7 
Size:	114.4 KB 
ID:	11685
    I need a query to get all the records for January Column. My SQL view of query looks like below.

    SELECT [Record Count].id_Date, [Record Count].[Total number of Successful Jobs], [Record Count].[Number of Jobs completed after manual run], [Record Count].[Number of Jobs completed after restart], [Record Count].[Number of jobs failed - No-follow-up Needed], [Record Count].[Number of jobs failed - Resolved by SPC Team], [Record Count].[Total Number of Jobs Monitored], [Record Count].Remarks
    FROM [Record Count]
    WHERE ((([Record Count]![id_Date]) Like "*January*"))
    ORDER BY [Record Count].id_Date;



    I am not getting what i need. Is there any modification i need to do to get only the records having the values January in the Date Field.

    Thanks in advance for any help you can offer on this.



    Thanks,
    Sarathi.

  2. #2
    Rawb is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    The problem is that, even though Access is displaying the date like "Monday, January 16, 2012", that's not how the data is actually being stored. Probably the easiest way would be to use the DatePart Function to pull out only the portion you want to compare:

    Code:
    WHERE ((DatePart("m",[Record Count]![id_Date]) = 1) AND (DatePart("yyyy",[Record Count]![id_Date]) = 2012))
    If you use the above WHERE condition, it will look for any results that include both the year 2012 and the month 1 (January).

  3. #3
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Try:
    WHERE (((Month([Record Count]![id_Date])) = 1))
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  4. #4
    sarathicse is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2013
    Location
    Chennai, India
    Posts
    3
    Thanks guys both the condition worked. Now I have one more question. I am using this in a Form.

    The form looks like below.Click image for larger version. 

Name:	temp.jpg 
Views:	4 
Size:	21.3 KB 
ID:	11687

    Now i have two parameter in query to get the value from the form.

    The year part i have no difficulties. But in Month part my client expect me to have a List of all the months.

    But in the query we are having number based conditions for Month.

    Is there a way to convert the Month we got from the list to numeric.

    Thanks in advance.

    Sarathi.

  5. #5
    Rawb is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    Just make the Combo Box two columns instead of one. Then put the month numbers in the first column and set the column width to 0" to hide it.

  6. #6
    sarathicse is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2013
    Location
    Chennai, India
    Posts
    3
    Thanks Rawb,

    That worked Perfect. I am entirely new to Access and this is my first post in this forum and I am more than satisfied with you guys response.

    Thanks again.

  7. #7
    Rawb is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    I'm glad we could help!

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

Similar Threads

  1. Replies: 2
    Last Post: 01-30-2013, 07:34 PM
  2. Replies: 3
    Last Post: 01-15-2013, 01:58 PM
  3. Replies: 1
    Last Post: 07-26-2012, 10:51 AM
  4. Replies: 1
    Last Post: 06-09-2012, 05:44 PM
  5. Replies: 7
    Last Post: 05-02-2012, 08:04 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