Results 1 to 6 of 6
  1. #1
    ocampod is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2010
    Posts
    11

    Limit Query Results

    Hello,



    I created a small project tracking database for our department. It has the following structure:

    1. Master Project Table - lists and contains information about the project
    2. Project Log - items associated to the project (one-to-many relationship)
    3. Action Items - action items related to any project log (one-to-many relationship)


    I can create a query and generate a report just fine. However, my problem is in the presentation of the data.

    What I am trying to generate is a report that shows the project ID (found in the Master Project Table), the associated Project Logs and the associated Action Items.

    My main problem, however, is that when I do that. I get redundant rows in my report which stems from the query. Obviously, this isn't pretty and I would like to find a way to group it without showing duplicate rows.

    Any help?

    Attached is an example of my issue.

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by ocampod View Post
    My main problem, however, is that when I do that. I get redundant rows in my report which stems from the query. Obviously, this isn't pretty and I would like to find a way to group it without showing duplicate rows.
    I don't follow your post completely, but if you're looking to eliminate duplicate rows from a dataset, this function might be useful to you:

    Code:
    Function DeleteDups(tblName As String)
    
    On Error Resume Next
    
    '******************************************************************************
    '                                                                             *
    'Author: Adam Evanovich                                                       *
    'Date: 11/11/2010                                                             *
    'Purpose: Deletes duplicate records in a single table.                        *
    '                                                                             *
    'Arguments:                                                                   *
    'tblName > Your table.                                                        *
    '                                                                             *
    '******************************************************************************
    
    Dim tempTbl As String
    Dim tempSql As String
    Dim db As DAO.Database
    Set db = CurrentDb
    tempTbl = db.TableDefs(tblName).Name
    
       If err.Number = 3265 Then
          MsgBox "Table does not exist!"
             GoTo Exit_Handle
       Else
          tempTbl = tblName & "2"
       End If
    
    On Error GoTo Err_Handle
    
       tempSql = "SELECT DISTINCT *" & _
                " INTO " & tempTbl & _
                " FROM " & tblName
    
          db.Execute tempSql, dbFailOnError
          db.TableDefs.Delete (tblName)
          DoCmd.Rename tblName, acTable, tempTbl
          db.TableDefs.Refresh
    
    Exit_Handle:
       db.Close
          Set db = Nothing
             Exit Function
    
    Err_Handle:
       MsgBox err.Description
          Resume Exit_Handle
    
    End Function '//LL

  3. #3
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Do you know about the keywords "Distinct" and "DistinctRow" when creating a select query? You have to type it in when in SQL view of the query.

    Look in help or google "SELECT DISTINCT" and "SELECT DISTINCTROW".

  4. #4
    ocampod is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2010
    Posts
    11
    Hi Adam and Steve,

    Thanks for your help. I am attaching a screenshot of my issue.

    • The first column has the Project ID from the Master Project Table
    • The second column has the Project Phase from the Master Project Table
    • The third column has the Project Status from the Master Project Table
    • The fourth column has Project Log item from the Project Log Table and is associated to the Master Project Table (one Project has many Project Logs)
    • The fifth column has the Project Log Description from the Project Log Table
    • The sixth column has the Action Item from the Action Item Table and is associated to the Project Log Table (one Project Log can have multiple Action Items)
    • The seventh column has the Action Item Description


    My problem, however, is that when I create a report based on this query, I get this exact result when I am looking for more of cascaded format (please see the "Reporting Ideal" image).

    I tried tweaking it within the report itself, but I figure the problem is within my query.

  5. #5
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    The query looks fine.

    ....... I am looking for more of cascaded format (please see the "Reporting Ideal" image).
    For reports, you need to use "Sorting and Grouping" under the VIEW menu.

    You can select the order of the fields to sort by. For each field in the grid, you can select if you want a group header (set Group Header to "YES"). Then in each group detail, put the fields you want to see in that group detail.

  6. #6
    ocampod is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2010
    Posts
    11
    Thanks for all the support guys! I was able to manipulate the data per your feedback.

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

Similar Threads

  1. Replies: 6
    Last Post: 05-14-2012, 07:24 AM
  2. Limit Query results to 5 contacts per site
    By wobvintage3 in forum Queries
    Replies: 2
    Last Post: 12-01-2010, 12:23 PM
  3. Excel Query Limit
    By Afliege in forum Queries
    Replies: 0
    Last Post: 03-19-2010, 10:20 AM
  4. Replies: 4
    Last Post: 02-08-2010, 11:17 AM
  5. Replies: 2
    Last Post: 08-04-2008, 04:16 PM

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