Page 2 of 2 FirstFirst 12
Results 16 to 25 of 25
  1. #16
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Note: "State", "Description" and "Type" are all RESERVED words in Access and shouldn't be used for object names.

    I commented out the lines
    Code:
    DoCmd.SetWarnings False
    DoCmd.SetWarnings True
    Then single stepped through the code. The "DoCmd.RunSQL "INSERT INTO....." line errored out. It did not append a record to table "AsmtPayments".


    I rewrote it using the Single-record append query version:


    Code:
    <snip>
        P = Me.payment
        dtPD = Me.DatePaid        '<<-- I added this variable
        MbrID = Me.MemberID     '<<-- I added this variable
    
        'Add to payments
        strsql = "INSERT INTO AsmtPayments (PaymentAmount, MemberID, PaymentDate )"
        strsql = strsql & " VALUES (" & P & ", " & MbrID & ", #" & dtPD & "#);"
    '    Debug.Print strsql
        CurrentDb.Execute strsql, dbFailOnError
    
    ' <snip>'
    The record was added to the table "AsmtPayments".
    But, nowhere in the loop code do I see anyway to add a record for a payment or changes the balance...??



    Would you explain what is supposed to happen?
    A record can be added on the "members" form in the accounts sub form, a record can be added in the "AccountsandPayments" form and one or more records could be created using the "Process Pmt." button.

    I re-read your posts and I am unsure what you are trying to do. I don't see how a payment is being split to pay the oldest charge first.
    And I am confused as to why you have 4 tables for charges and payments.




    --------------------------------------------------------------------------
    I would also advise against displaying autonumber fields on a form/report.

    AutoNumber
    ----------------
    Purpose: Use an AutoNumber field to provide a unique value that serves no other purpose than to make each record unique. The most common use for an AutoNumber field is as a primary key.
    Autonumbers--What they are NOT and What They Are

  2. #17
    Gina Maylone is offline Always learning
    Windows 10 Access 2016
    Join Date
    Jun 2013
    Location
    Afton, MN
    Posts
    544
    [QUOTE=ssanfu;393354]Note: "
    State
    ", "
    Description
    " and "
    Type
    " are all
    RESERVED words
    in Access and shouldn't be used for object names.
    Thanks, I'll change them.
    I commented out the lines
    Code:
    DoCmd.SetWarnings False
    Code:
    DoCmd.SetWarnings True

    Then single stepped through the code. The "DoCmd.RunSQL "INSERT INTO....." line errored out. It did not append a record to table "AsmtPayments".


    I rewrote it using the Single-record append query version:
    Code:
    <snip>
    Code:
        P = Me.payment
        dtPD = Me.DatePaid        
    Code:
    '<<-- I added this variable
    
    MbrID = Me.MemberID
    '<<-- I added this variable
    'Add to payments strsql = "
    INSERT INTO AsmtPayments (PaymentAmount, MemberID, PaymentDate )
    " strsql = strsql & "
    VALUES (" & P & ", " & MbrID & ", #" & dtPD & "#)
    ;" ' Debug.Print strsql CurrentDb.Execute strsql, dbFailOnError ' <snip>'

    The record was added to the table "AsmtPayments".
    But, nowhere in the loop code do I see anyway to add a record for a payment or changes the balance...??



    Would you explain what is supposed to happen?
    Code:
    Option Compare DatabaseOption ExplicitPrivate Sub Command52_Click()    DoCmd.SetWarnings False    Dim strsql As String    Dim BD As Variant    Dim BL As Variant    Dim CR As Variant    Dim db As Variant    Dim tb As Variant    Dim P As Variant    Dim expr2 As Variant    BD = Me.baldue    BL = Me.balleft    CR = Me.CRAmount    db = Me.DBAmount    tb = Me.totalbal    P = Me.payment    'Add to payments    DoCmd.RunSQL "INSERTINTO AsmtPayments ( PaymentAmount, MemberID, PaymentDate ) " & vbCrLf& _                 "SELECT[payment] AS Expr1, Accounts.MemberID,[Forms]![AccountsandPayments]![Accountssubform].[Form]![datepaid] AS Expr2" & vbCrLf & _                 "FROMAccounts " & vbCrLf & _                 "WHERE(((Accounts.MemberID)=[Forms]![AccountsandPayments]![MemberID]));"    DoCmd.SetWarnings True    Requery‘*****Go to the account subform and go to the first record (which willbe the oldest assessment)   Forms![accountsandpayments]![Accountssubform].SetFocus   Forms![accountsandpayments]![Accountssubform].Form![DateAssessed].SetFocus    Do While BL > 0        DoCmd.GoToRecord , ,acFirst
            '**********EXACTPAYMENT****        While BL >= tb And tb> 0 and CR=0 (just added this final parameter)            If CR <> dbThen                CR = CR + BL            End If            BL = 0            DoCmd.GoToRecord , ,acNext        Wend        If BL = 0 Then            Exit Sub        End If        '**********FIRSTLOOP************‘*****there is money to pay assessment(s) and there is a balance due.        While BL >= BD And BD> 0            Debug.Print"meets first loop criteria"            Debug.Print BL            Debug.Print BD            Debug.Print CR            Debug.Print db            Debug.Print BDCR = CR + BD ‘ (note, these lines were missing, don’tknow where they went)               BL = BL - BD            DoCmd.GoToRecord , ,acNext        Wend        '*******************        '**********SECOND LOOP***                ‘***WHOOPS, thisjust duplicates the first loop. My bad        While BL > 0 And BL>= BD And BD > 0            Debug.Print"meets the second loop criteria"            CR = CR + BD            BL = BL - BD            'DatePaid1 = DatePaid            'PostedBy =[Forms]![AccountsandPayments]!user            DoCmd.GoToRecord , ,acNext        Wend        '************************        '***********THIRD LOOP***        While BL > 0 And BD> 0 And CR < db and CR>0 ‘I was missing the final parameter again‘***This looks for a previous partial pay of an assessment ***            Debug.Print"meets the third loop criteria"            Debug.Print CR <db            CR = CR + BL            BL = BL - CR            DoCmd.GoToRecord , , acNext        Wend        '************************        '*****Overpayment createsa new credit record not related to a debit.        '    If BL > 0 And totalbal = 0 Then        '        '   DoCmd.GoToRecord , , acNewRec        '    DatePaid1 = DatePaid        '    PostedBy =[Forms]![AccountsandPayments]!user        '    CR = BL        '    BL = BL - CR        '    BL = 0        '    IfNote = "" Then ''add a note to a new record only        '    Note = "Over Pmt" & "" & DatePaid1 & " " & CheckNum        '    DoCmd.GoToRecord , , acNext        '    Wend        Exit Do    LoopEnd Sub

    A record can be added on the "members" form in the accounts sub form, a record can be added in the "AccountsandPayments" form and one or more records could be created using the "Process Pmt." button.
    This "CR = CR + BL" sets the credit amount which updates the baldue (calculated control on subform). In the subform "Baldue=(Nz([dbamount],0)-Nz([cramount],0)"

    I re-read your posts and I am unsure what you are trying to do. I don't see how a payment is being split to pay the oldest charge first.
    And I am confused as to why you have
    4 tables
    for charges and payments.
    sure
    Not sure what 4 tables you're referring to. Accounts covers the assessments and payments. AsmtPayments is a permanent record of all payments, for accounting purposes. I use the AccountsQuery to sort by oldest to newest date. Please clarify and I will explain.




    --------------------------------------------------------------------------
    I would also advise against displaying autonumber fields on a form/report.
    Yes, the membered is an autonumber, no good reason to have it be something else. So it's necessary to have it be visible.

  3. #18
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Quote Originally Posted by Gina Maylone View Post
    The record was added to the table "AsmtPayments".
    But, nowhere in the loop code do I see anyway to add a record for a payment or changes the balance...??
    Would you explain what is supposed to happen?

    This "CR = CR + BL" sets the credit amount which updates the baldue (calculated control on subform). In the subform "Baldue=(Nz([dbamount],0)-Nz([cramount],0)"
    "CR" is a variable in code - can't see where it (the value) is being saved to a form control or to a table.



    Quote Originally Posted by Gina Maylone View Post
    Not sure what 4 tables you're referring to. Accounts covers the assessments and payments. AsmtPayments is a permanent record of all payments, for accounting purposes. I use the AccountsQuery to sort by oldest to newest date. Please clarify and I will explain.

    These are the 4 tables I was asking about
    Click image for larger version. 

Name:	Tables1.png 
Views:	23 
Size:	107.4 KB 
ID:	33480


    Quote Originally Posted by Gina Maylone View Post
    I would also advise against displaying autonumber fields on a form/report.
    Yes, the membered is an autonumber, no good reason to have it be something else. So it's necessary to have it be visible.
    See
    Autonumbers--What they are NOT and What They Are
    Microsoft Access Tables: Primary Key Tips and Techniques

    Autonumbers can go negative....

    -----------------------------------------------------------------------------------------------

    So you click buttons and finally arrive at the form "MEMBER ASSESSMENTS and PAYMENTS".
    There is a subform, "Accountssubform" (source = Copy Of Accounts2), where you can enter payments.
    The current record is for "SHORT, JIM or MARY" with a balance of $94.07.
    What are the steps to enter the payment?

    Do you enter the amount into the 3 unbound controls next to the button "Process Pmt"? What should happen then/what do you want to happen??

    Do you enter info into the detail section in the subform?

    In which of the 4 tables should records be created? Probably not late fees, unless there is a "late fee" record in Accounts??

  4. #19
    Gina Maylone is offline Always learning
    Windows 10 Access 2016
    Join Date
    Jun 2013
    Location
    Afton, MN
    Posts
    544
    I will answer your questions here first, but I decided to put my big girl panties on and try using a recordset like other grown ups...since at one time, a really smart guy gave me some excellent examples of recordsets.

    Do you enter the amount into the 3 unbound controls next to the button "Process Pmt"? YES. What should happen then/what do you want to happen?? I WANT IT TO LOOP THROUGH AND ADD THE PAYMENT AMOUNT (CRAMOUNT) FOR THE OLDEST ASSESSMENT FIRST. IF THERE IS MONEY LEFT OVER A NEW RECORD SHOULD BE CREATED WITH THE (LEFTOVER) CRAMOUNT FILLED IN. IN THE EXAMPLE OF JIM AND MARY SHORT, THEY MADE A PAYMENT OF $400 TO BEGIN WITH ON 4/10 (OR WHATEVER) WHICH WOULD COVER JAN, FEB AND PART OF MARCH ($94.07 BAL DUE FOR MARCH) THE NEXT PAYMENT THEY MAKE IS $94.07, I WANT THE FUNCTION TO FIND THE RECORD WITH THE BALANCE DUE AND APPLY THE CREDIT OF $94.07 (IN THIS CASE, THE MARCH ASSESSMENT) SORRY FOR ALL CAPS, I'M REALLY NOT YELLING, MY MONITOR IS DISPLAYING ONLY BLACK AND WHITE (JUST ORDERED A NEW ONE), SO I CAN'T USE COLORS.
    Do you enter info into the detail section in the subform? NO.
    In which of the 4 tables should records be created? Probably not late fees, unless there is a "late fee" record in Accounts??
    ONLY 2 TABLES, ACCOUNTSANDPAYMENTS AND ASMTPAYMENTS. THE MEMBERASSESSMENTS THAT YOU INQUIRED ABOUT KEEPS TRACK OF WHO GETS ASSESSED WHAT AND HOW MUCH. IT'S USED IN RUNNING THE ASSESSMENTS.

    I'm going to start a new post now. With my recordset questions. Thanks Steve!

  5. #20
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Gina,

    I've worked on your code problem again and made some changes.

    In table "AssessmentTypesandAmounts", I added a value "Credit Amount" that is needed in the code to find credit amount records.
    For member #6, Baker, Jerry, I updated the "Asmt. Type" value for the credit. Every credit record MUST have the "Asmt. Type" set to "Credit Amount" for the code to function correctly. Any NEW credit record will have the "Asmt. Type" set to "Credit Amount".

    I added code to clear the date paid, amount and check number. Look at the last 3 lines in the button code.

    I've some some testing and I think (hope) I've got it right..

    Also, I couldn't remember the member names so I added a combo box to help me. You can click on the drop down arrow or start typing the lastname.... for example, enter "W" and click the dropdown to go to the "W"s. Or type "Wi" to get to Williams.... (should also work for business names)
    Attached Files Attached Files

  6. #21
    Gina Maylone is offline Always learning
    Windows 10 Access 2016
    Join Date
    Jun 2013
    Location
    Afton, MN
    Posts
    544
    Hi Steve,

    Thank you, I'm sorry I've been so unavailable, it's been crazy. I tried to look at the code, got an error about Excel, and it froze up. I imagine I need to set a reference. Oh! And regarding the search field, I have tried to talk them into a drop down, but they like it the way it is, they are used to it.

    Thank you again and again. :-)

  7. #22
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Quote Originally Posted by Gina Maylone View Post
    I tried to look at the code, got an error about Excel, and it froze up. I imagine I need to set a reference.
    That is really strange. There is no reference set to/for Excel in my copy of the dB.
    I do have a reference set to Office xx.0 Access database engine Object Library. (my version is 14.0)

    Let me know if it continues to freeze. I'll do a decompile & recompile.

  8. #23
    Gina Maylone is offline Always learning
    Windows 10 Access 2016
    Join Date
    Jun 2013
    Location
    Afton, MN
    Posts
    544
    I closed it and reopened and it was fine. I had a few computer issues yesterday so that might have been it. It works perfectly of course. You. Are. A. ROCK. STAR.

  9. #24
    Gina Maylone is offline Always learning
    Windows 10 Access 2016
    Join Date
    Jun 2013
    Location
    Afton, MN
    Posts
    544
    Hi again,

    Do you have any tricks up your sleeve for a dynamic crosstab subform that displays a members assessments as appropriate? If not, don't worry about it!

  10. #25
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Not off hand. It has been a long, long time since I played around with crosstab queries.

    Maybe this will help??
    How to Create a Crosstab Query in Design View in Access

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 9
    Last Post: 03-07-2017, 02:49 PM
  2. Replies: 6
    Last Post: 12-01-2016, 03:40 PM
  3. Replies: 12
    Last Post: 06-05-2015, 04:27 PM
  4. Replies: 13
    Last Post: 08-20-2014, 09:17 AM
  5. Replies: 17
    Last Post: 04-07-2014, 07:48 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