Results 1 to 6 of 6
  1. #1
    MLK is offline Novice
    Windows 8 Access 2007
    Join Date
    May 2020
    Posts
    6

    Need a help for a Query by Charge and payment tables

    Dear Team,

    Kindly look into the the attached acbd. it contains 2 tables. Charge table has charge amounts for each visit #. Payment table has payments which received for each Visit by payment type. i need to create a Query which given following result.



    Click image for larger version. 

Name:	Summary.jpg 
Views:	12 
Size:	31.3 KB 
ID:	41751

    I have created a query , but it doesn't give correct details. Charge amount has duplicated. I need to take sum of payments of each visit.

    I got the following result from query.

    Click image for larger version. 

Name:	Result.jpg 
Views:	12 
Size:	65.4 KB 
ID:	41752

    Could please help me for this.

    Thanks for your time.

    MLK.
    Attached Files Attached Files

  2. #2
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,820
    Hi MLK

    You are best to view the data as shown in the attached Db

    Also look at the example query
    Attached Files Attached Files

  3. #3
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,180
    Hi, you can solve this by making 2 queries:
    one totals query qtotPayments to get the total amount payed:
    Code:
    SELECT Payment.[Visit #], Sum(Payment.[Payment Amount]) AS [SumOfPayment Amount]
    FROM Payment
    GROUP BY Payment.[Visit #];
    and then the second query linking the totals query to the charge table:

    Code:
    SELECT Charge.[Visit #], Charge.[Charge Amount], qtotPayments.[SumOfPayment Amount]
    FROM qtotPayments INNER JOIN Charge ON qtotPayments.[Visit #] = Charge.[Visit #]
    ORDER BY Charge.[Visit #];
    

  4. #4
    MLK is offline Novice
    Windows 8 Access 2007
    Join Date
    May 2020
    Posts
    6
    Dear Mike,

    Thank you very much for the time and support.

    Actually I am looking for a Query which give above result.

    Thanks
    MLK.

  5. #5
    MLK is offline Novice
    Windows 8 Access 2007
    Join Date
    May 2020
    Posts
    6
    Dear NoellaG,

    Thank you very much for the support and time.

    You have solved this problem.

    Really Appreciate you support.

    MLK.

  6. #6
    MLK is offline Novice
    Windows 8 Access 2007
    Join Date
    May 2020
    Posts
    6
    Dear NoellaG,

    When i use your method with my acdb , i have noticed that, there are some visits without any payments. There are no records for those in Payment table. but charge value is still there in Charge table. Kindly look into attached acbd. ( Visit # 4, charge value is $400, but no payment received for that, there for no recoards in payment table). My requirement is, i need to show them as "0", bcoz charge value is existing. I need final result as below.

    Click image for larger version. 

Name:	Result 2.jpg 
Views:	5 
Size:	33.5 KB 
ID:	41762

    Could you please check and let me know a method.

    Thank you very much for your time.

    MLK.
    Attached Files Attached Files

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

Similar Threads

  1. Replies: 6
    Last Post: 08-10-2017, 02:42 PM
  2. Replies: 11
    Last Post: 11-28-2015, 10:14 PM
  3. Replies: 3
    Last Post: 04-18-2015, 12:01 PM
  4. Replies: 5
    Last Post: 08-11-2014, 10:08 AM
  5. Total charge , creating a query
    By lasts3cond in forum Queries
    Replies: 1
    Last Post: 12-03-2013, 04:57 PM

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