Results 1 to 9 of 9
  1. #1
    HK123 is offline Novice
    Windows 11 Office 365
    Join Date
    Dec 2023
    Posts
    21

    Is it possible to hide/prevent duplicates for SOME data in a query?

    Hello, I am very new to Access and self taught by YouTube / Google and by no means a "computer" person. My apologies if I am therefore using incorrect terminology.

    I have a query that pulls info from a main order form and its sub form with the item details. I have totals on the main order that I would like to show up only once in my query, while still displaying the information of each item. I have gotten this idea to work on a report I created based on the query by highlighting the text boxes for the data I did not want to repeat and clicking yes on the hide duplicates within the property sheet.

    I am assuming this can not be done in a query, but as I said I do not actually know that much about Access yet, and have been surprised a few times at what is possible. I am doing most of my work in design view and have just barley started to dabble in macro functions. If it is possible and anyone knows a good reference article or YouTube video on how to accomplish this I would greatly appreciate it! Or just let me know its impossible so I can stop looking (:

    Thank you!

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Not sure but what you're describing might need a Totals query. Suggest you google 'ms access Totals query' before trying it in query design view. IIRC it is the Sigma button on the ribbon. Σ
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    I am assuming this can not be done in a query
    It can probably be done in a query - suggest show some example data and the outcome required to make sure we understand what the requirement actually is.

  4. #4
    HK123 is offline Novice
    Windows 11 Office 365
    Join Date
    Dec 2023
    Posts
    21
    Thanks all, with more research it appears it was not possible to achieve my results in a query. I was however able to export into excel and then with a bit of formatting get the desired results.

  5. #5
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,044
    Some things that cannot be done in 1 query can be done when combining two queries. You can create a totals query and combine it with a query showing detail records.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I am sure it can be done - involves a UNION query. Something like:

    SELECT ProdID, Product, Quantity FROM OrderDetails INNER JOIN Products ON OrderDetails.ProdID = Products.ProdID
    UNON SELECT "Total", Product, Sum(Quantity) FROM OrderDetails INNER JOIN Products ON OrderDetails.ProdID = Products.ProdID GROUP BY Product
    ORDER BY Product, ProdID;

    However, if you want to display more fields from OrderDetails, will get more complicated.

    SELECT ProdID, Product, OrderNum, Quantity FROM OrderDetails INNER JOIN Products ON OrderDetails.ProdID = Products.ProdID
    UNON SELECT ProdID, Product, Total, Null FROM (SELECT "Total" AS ProdID, Product, Sum(Quantity) AS Total FROM OrderDetails INNER JOIN Products ON OrderDetails.ProdID = Products.ProdID GROUP BY Product) AS Q1
    ORDER BY Product, ProdID;
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    Salty Mariner is offline Intermediate
    Windows 11 Access 2021
    Join Date
    Dec 2023
    Location
    Corpus Christi, TX
    Posts
    69
    Quote Originally Posted by HK123 View Post
    Hello, I am very new to Access and self taught by YouTube / Google and by no means a "computer" person. My apologies if I am therefore using incorrect terminology.

    I have a query that pulls info from a main order form and its sub form with the item details. I have totals on the main order that I would like to show up only once in my query, while still displaying the information of each item. I have gotten this idea to work on a report I created based on the query by highlighting the text boxes for the data I did not want to repeat and clicking yes on the hide duplicates within the property sheet.

    I am assuming this can not be done in a query, but as I said I do not actually know that much about Access yet, and have been surprised a few times at what is possible. I am doing most of my work in design view and have just barley started to dabble in macro functions. If it is possible and anyone knows a good reference article or YouTube video on how to accomplish this I would greatly appreciate it! Or just let me know its impossible so I can stop looking (:

    Thank you!
    Have you considered using a subReport on a form? You can use the Grouping and Totals functions of the report If you are not going to edit the data this would accomplish what you want since you already figured that out. and if you do need to modify it. I did that in the picture below. If the user needs to change the record I have a click event attached to the textbox for the document name. I formatted it to "look" like a hyperlink so the user has a visual clue that it actually does something. That in turn opens another form to actually edit the data. It works great. Just shrink the subReport to fit on your form. In my case the detail section of the report behaves just like continuous forms.
    Click image for larger version. 

Name:	Screenshot 2023-12-27 134553.png 
Views:	27 
Size:	35.8 KB 
ID:	51259
    Something to think about and perhaps play around with.

  8. #8
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    still guessing as to what your actual output is required but this link might give you some idea's - all done with queries

    https://www.access-programmers.co.uk...report.326715/

    first example looks like this
    Click image for larger version. 

Name:	image_2023-12-28_182010098.png 
Views:	19 
Size:	150.0 KB 
ID:	51264

    colors are a feature of the form rather than the underlying query

  9. #9
    HK123 is offline Novice
    Windows 11 Office 365
    Join Date
    Dec 2023
    Posts
    21
    Thanks everyone! I am going to look into these suggestions! it appears some of these may work for what I need.

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

Similar Threads

  1. Query to prevent duplicates with criteria
    By Hursan in forum Queries
    Replies: 4
    Last Post: 08-06-2022, 11:31 PM
  2. Hide Duplicates in a Query Across Two Fields
    By ItsRoland in forum Queries
    Replies: 4
    Last Post: 04-01-2019, 01:53 PM
  3. Prevent Duplicates
    By Koolaid in forum Access
    Replies: 4
    Last Post: 03-31-2016, 09:37 AM
  4. Replies: 3
    Last Post: 09-11-2015, 03:22 PM
  5. How to prevent duplicates in said example
    By raymondbeckham in forum Forms
    Replies: 1
    Last Post: 04-11-2012, 03:29 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