Results 1 to 4 of 4

Thread: Access Query [Resolved]

  1. #1

    Thread Starter
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Resolved Access Query [Resolved]

    I have an Access db, and I'm thinking about redoing the actual table to let it include transactions. The client has 4 sites, and wants to use a db with all the records in each site. I need a query to select each record.name and a sum of all the payments. Not sure how to do it.

    VB Code:
    1. cn.Execute "Insert into paymentrecord " & _
    2.       "(LastName, Firstname, LastPayDate, BalanceDue, AmountPaid) " & _
    3.       "Values ('" & txtLastName.Text & "','" & txtFirstName.Text & "','" & _
    4.        CDate(txtLastPaymentDate.Text) & "','" & txtBalanceDue.Text & "','0')"

    There are the fields that I use. I'm going to use a LastPayDate and Amount Paid for each time the client makes a payment. I need to group by lastname, firstname, and calculate the total payment amount. I'l load the result into a listbox like I do now, but if they add records from a different office, it will also work. I'll make the LastPaymentDate a key field so there can't be dups. Only one payment per key record allowed.

    Thanks.
    Last edited by dglienna; Jun 7th, 2005 at 05:03 PM.

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Access Query

    How's this?
    Code:
    SELECT LastName, Firstname, Sum(AmountPaid)
    FROM paymentrecord 
    GROUP BY LastName, Firstname
    (seems too easy!)

  3. #3

    Thread Starter
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Access Query

    Thanks. I've played around with it today, and decided that I probably need to use two tables. One with the names, and the other as a listitem table. I'll be back when I need to use a join to the two.

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Access Query [Resolved]

    That sounds good, here's a quick design for you (based on your current data):
    Code:
    tblPeople
      PersonID (unique ref)
      LastName
      Firstname
    
    tblPayment
      PersonID (link to tblPeople)
      LastPayDate
      BalanceDue 
      AmountPaid
    I think the tblPayment table needs a redesign, but how depends on exactly how it should work. Possibly this:
    Code:
    tblPaymentsMade
      PersonID (link to tblPeople)
      PayDate  (you can calculate a "last paid" date from this)
      AmountPaid
    
    tblAmountOwed
      PersonID (link to tblPeople)
      DateOwed
      BalanceDue

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width