Results 1 to 12 of 12
  1. #1
    New Comer is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2025
    Posts
    10

    Lightbulb Need Help for Creating Report Ms Access

    Dear All Honorable,

    I am making this database for our milk shop. Tables forms and queries have been made. Now I want to create a report. 4 queries have been created for the report. 1 for Report Customer Queries(main Report). AND 2. Purchase Detail Query, 3. Product Amount Query, and Payment Detail Query.( maybe subreport or what you suggest)
    Click image for larger version. 

Name:	Untitled-1 [Recovered].jpg 
Views:	51 
Size:	144.1 KB 
ID:	52795
    I want to make the report according to this image. But I don't know exactly how it will happen. I sincerely hope that you will definitely help me in this regard. I need a form and an on-click VBA script that searches on monthly bases and not dates. And similarly, the summary report of whatever the customer has purchased throughout the month should be displayed as per the image. Please guide me step by step.
    Thank you all so much.

    ** This is My 1st Time with MS access or any Database Application, Please Help
    Thanks

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    The summary data for each product can be generated in report design using Sorting & Grouping features with expressions in textboxes, like:

    =Sum(IIf(Product = "Milk", Quantity, Null))

    The total is simply =Sum(Quantity)

    Those textboxes would be in a group footer section. Do research on building report with Sorting & Grouping. This is basic Access functionality.

    The Paid and Remaining calcs will be most complicated aspect.

    If you want to provide db for analysis, follow instructions at bottom of my post.
    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.

  3. #3
    New Comer is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2025
    Posts
    10

    Thanks to June7 (File Attached)

    Thank You @June7
    You are so Kind Thank You here is My Access File:
    Attached Files Attached Files

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    A subreport is one way to go but not really necessary in this case. The Paid and Remaining calcs were simple because you are saving payment data in Sales table. Review attached Munasib.zip

    If there can be different types of milk/yoghurt/butter, some modifications will be required.

    Customer name should not be in Sales table - I deleted field. Calculated data like Total and Remaining should not be saved to table. These should be calculated when needed. Can use Calculated type field in table but calculation in query or textbox is adequate.

    Advise not to use exact same field name in multiple tables, such as CustomerID. I would use CustomerID_FK in Sales.
    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.

  5. #5
    New Comer is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2025
    Posts
    10

    Thanks to June7 (File Attached)

    Quote Originally Posted by June7 View Post
    A subreport is one way to go but not really necessary in this case. The Paid and Remaining calcs were simple because you are saving payment data in Sales table. Review attached Munasib.zip

    If there can be different types of milk/yoghurt/butter, some modifications will be required.

    Customer name should not be in Sales table - I deleted field. Calculated data like Total and Remaining should not be saved to table. These should be calculated when needed. Can use Calculated type field in table but calculation in query or textbox is adequate.

    Advise not to use exact same field name in multiple tables, such as CustomerID. I would use CustomerID_FK in Sales.
    Thank You June7 َ
    Your kindness and guidance has impressed me a lot. In the light of this, I tried something else through which I got some good results. But there is one problem which is not being solved. The results are getting mixed. February and March (these are the only entries) i.e. the correct data of the customer name is being filtered but the month is getting mixed. Apart from this, the entire result is being repeated 3 times. What should I do sir!!
    here is Image... Click image for larger version. 

Name:	mixdata.png 
Views:	31 
Size:	24.5 KB 
ID:	52829

  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    You need to sort by date as well in report.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    The report I provided you works. So what have you done differently? I expect you did something in the query. Provide your code or another db.
    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.

  8. #8
    New Comer is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2025
    Posts
    10
    Quote Originally Posted by June7 View Post
    The report I provided you works. So what have you done differently? I expect you did something in the query. Provide your code or another db.
    Dear Sir! I have learned so much from your guidance, when I posted earlier I did not understand Access. I will always be grateful to you. Sir, even then I had written that I want a summary, Sir, if you look at the first row of the image, you will see that milk is 35.85 kg. This is a summary of a month. Now the summary is created but the results are getting mixed. The customer name and purchase are also correct but the result of both the months is showing together. It is not being resolved by group and sort.

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Again, it works in the file I provided you. Dates are NOT mixed and NOT repeated within vendor and data is summarized in footer sections. You have changed what I provided but I am not sure what you did. Show your code.

    If you don't want to show detail records, the Detail Section can be set to Visible No while you do summary calcs in group footers. Otherwise, the RecordSource SQL would be like:

    Code:
    SELECT Customers.CustomerID, Customers.CustomerName, Customers.CustomerAddress, Customers.CustomerPhone, Products.ProductID, Products.ProductName, 
                Sum([Quantity]*[PricePerUnit]) AS SumTotal, Sum(Sales.PaidAmount) AS SumPaid,
                Format([SaleDate],"yyyymm") AS YearMo, Format([SaleDate],"mmm yyyy") AS MonYear
    FROM Products INNER JOIN (
              Customers INNER JOIN 
                     Sales ON Customers.CustomerID = Sales.CustomerID) ON Products.ProductID = Sales.ProductID
    GROUP BY Customers.CustomerID, Customers.CustomerName, Customers.CustomerAddress, Customers.CustomerPhone, Products.ProductID, Products.ProductName, Format([SaleDate],"yyyymm"), Format([SaleDate],"mmm yyyy");
    or
    Code:
    SELECT Customers.*, Products.ProductID, Products.ProductName, SumQ.*
    FROM (Customers 
    INNER JOIN (
            SELECT Sales.CustomerID, Sales.ProductID, Format([SaleDate], "mmm yyyy") AS MonYear, Format([SaleDate],"yyyymm") AS YearMo,
                        Sum([Quantity]*[PricePerUnit]) AS SumTotal, Sum(Sales.PaidAmount) AS SumPaid 
            FROM Sales GROUP BY Sales.CustomerID, Sales.ProductID, Format([SaleDate],"yyyymm"), Format([SaleDate], "mmm yyyy"))  AS SumQ 
    ON Customers.CustomerID = SumQ.CustomerID) 
    INNER JOIN Products ON SumQ.ProductID = Products.ProductID;

    If Unit is always KG, don't need to save this into table. If unit can be different, then it becomes meaningless when data is aggregated.
    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.

  10. #10
    New Comer is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2025
    Posts
    10

    Lightbulb Need Help

    @JUNE7
    Dear Sir, I will be forever grateful for the way you guided me. I am still in the learning phase, what I need to do with the report is, if a customer buys milk 45 times in a month then the report will become very big, so I am taking only one line summary of the data wise instead of the entire month detail. In this way the summary of 10 products will be on one page.

    Here is file:
    Attached Files Attached Files

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    I have given you two ways to accomplish that.
    First is to use the report I already provided and simply set Detail section to Visible No.
    Other is to use a query that aggregates data as report RecordSource. I showed you two queries.

    In both approaches, would still use Sorting & Grouping with Sum() calcs in footer section and NO subreport.

    Your latest attempt still utilizes a subreport - why?
    Last edited by June7; 03-10-2025 at 09:17 PM.
    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.

  12. #12
    New Comer is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2025
    Posts
    10
    Thanks To all,
    Solved !!
    This is my first MS Access project. So I couldn't understand quickly where the mistake was. I understood the mistake, when I separated the month from the date, I deleted the date column after that, now I haven't deleted it... Now I am getting a single line summary of the entire month, no data mix-up, no duplication. Thank you all.

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

Similar Threads

  1. Replies: 2
    Last Post: 04-03-2016, 02:00 PM
  2. Need help creating library report
    By iansan5653 in forum Reports
    Replies: 5
    Last Post: 01-31-2012, 06:23 PM
  3. Need Help Creating Report Based on User Entry
    By italianfinancier in forum Programming
    Replies: 17
    Last Post: 05-27-2011, 04:58 AM
  4. I need help in creating a database report.
    By fastorm in forum Queries
    Replies: 1
    Last Post: 10-27-2010, 09:54 PM
  5. Need help on creating a type of Report
    By Accessorize in forum Reports
    Replies: 1
    Last Post: 08-20-2010, 02:57 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