Results 1 to 5 of 5
  1. #1
    Tommo is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Sep 2015
    Posts
    42

    Can't get payments system working

    I am trying to build a payments for a schools DB.

    I have tblStudents, tblClasses, tblEnrollments links them in a many to many.

    I also have tblPayments which is linked with an EnrolmentsID_(Foreign Key).

    Now a few problems.

    I am trying to build a totalPaid field in a datasheet for each enrollment. I have the following;

    =Nz(DSum("AmountPaid","tblPayments",DLookUp("Enrol lmentsID_FK","tblPayments")=[EnrollmentsID]),0)



    This is only comparing the first Foreign Key in tblPayments table and totalling all the payments in to that field on my data sheet. What am I doing wrong please.


    Also I want to build a payments form where I can pick a class then cascade to the students from this and then generate the correct enrollmentID from this to assign a payment. I can't seem to work this out at all.

    Any help would be appreciated.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    So this is on a form bound to tblEnrollments? Try:

    =Nz(DSum("AmountPaid", "tblPayments", "[EnrollmentsID_FK]=" & [EnrollmentsID]), 0)

    As for the payments form, you want to select a class then select a student already associated with that class? Maybe you need cascading comboboxes? http://datapigtechnologies.com/flash...combobox2.html
    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
    Tommo is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Sep 2015
    Posts
    42
    Yeh that works. Thanks.

    "[EnrollmentsID_FK]=" & [EnrollmentsID] What does this do please. Sorry I am new to this stuff.

    Also at the bottom of the table where the new field would go it has a #Error.

    It doesnt really matter but can I get rid of it easily?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Doubtful, but try:

    =Nz(DSum("AmountPaid", "tblPayments", "[EnrollmentsID_FK]=" & Nz([EnrollmentsID],0)), 0)
    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
    Tommo is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Sep 2015
    Posts
    42
    it works. Ta

    edit: no it doesnt. But thanks!

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

Similar Threads

  1. Trying to make payments system for dance school
    By Tommo in forum Database Design
    Replies: 15
    Last Post: 09-04-2015, 04:47 PM
  2. Payments Table and Form
    By Lou_Reed in forum Access
    Replies: 3
    Last Post: 04-14-2015, 03:03 PM
  3. Invoice and payments received
    By esther6086@lowcountry.com in forum Queries
    Replies: 1
    Last Post: 08-13-2013, 06:28 PM
  4. Need To Sum Payments in Query
    By burrina in forum Queries
    Replies: 3
    Last Post: 11-27-2012, 05:35 PM
  5. Replies: 3
    Last Post: 07-18-2011, 04:14 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