Results 1 to 2 of 2
  1. #1
    hpavay is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    1

    How to print out only most recent comment from a Work Order database

    Goal: Print out each work order with most recent comment only.

    I have the following so far, but I can only get the most recent "COMMENTDATE" to print, along with each work order.

    When I try using "dbo_comments.sys_comment" in the sub query, I receive an ERROR(This is the field name of the comment).

    SELECT dbo_request.sys_assignedto, dbo_request.sys_requestdate, dbo_request.sys_problemdesc, dbo_request.sys_requesttype_id, dbo_request.sys_solutiondesc, dbo_request.usr_lastname, dbo_request.sys_requestclosedate, (SELECT TOP 1 dbo_comments.sys_commentdate
    FROM dbo_comments
    Where dbo_request.sys_request_id = dbo_comments.sys_request_id
    Order by dbo_comments.sys_comment) AS Expr1
    FROM dbo_request


    WHERE (((dbo_request.sys_assignedto)=[Enter Analyst ID]) AND ((dbo_request.sys_requestclosedate) Is Null));

  2. #2
    kennejd is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    188
    Give this a try....you have some problems with your SQL. I changed the layout a little, but it should still work:

    SELECT
    d.sys_assignedto
    , d.sys_requestdate
    , d.sys_problemdesc
    , d.sys_requesttype_id
    , d.sys_solutiondesc
    , d.usr_lastname
    , d.sys_requestclosedate
    ,(SELECT top 1 c.sys_request_id, c.sys_comment
    FROM dbo_comments c
    WHERE c.sys_request_id = d.sys_request_id
    Order by c.sys_commentdate DESC)
    FROM dbo_request d


    WHERE
    (((d.sys_assignedto)=[Enter Analyst ID]) AND ((d.sys_requestclosedate) Is Null));

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

Similar Threads

  1. File Names in "Open Recent Database" list
    By Ron.Sul in forum Access
    Replies: 3
    Last Post: 12-29-2011, 10:06 AM
  2. Service Order Database - Novice Looking for help.
    By Patriot7470 in forum Database Design
    Replies: 3
    Last Post: 02-16-2011, 08:50 AM
  3. Generate Sum from a work center and order #
    By KrenzyRyan in forum Programming
    Replies: 2
    Last Post: 01-19-2011, 09:51 AM
  4. Comment History
    By botts121 in forum Programming
    Replies: 0
    Last Post: 07-02-2009, 01:02 PM
  5. Inserting Comment on a cell??
    By yotapower10 in forum Access
    Replies: 6
    Last Post: 06-29-2009, 08:20 AM

Tags for this Thread

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