R
Ray Todd
I have the below code. The problem that I am experiencing is that when I
enter a payment, the PaymentTotal *sometimes* results in zero despite payment
existing for that account. There is no rhyme or reason for the zero result,
it is purely random. When I enter a payment, it will sometimes come up on
the 1st pmt or not at all until the 18th payment entry.
So as to understand the setup of the forms:
form frmDEFENDANTSmain = the main 'database' window. This shows the
name/address as well as the total citations and the total payment received as
well as the resulting balance.
form frmPAYMENentry = the data entry window for payments.
form frmPAYMENTSscreen = A subform (of frmDEFENDANTSmain) that shows all of
the payments.
form frmCITATIONscreen = a subform (of frmDEFENDANTSmain) that shows all of
the citations for a particular defendant.
Any help and/or suggestions would be deeply appreciated.
Option Compare Database
Private Sub Form_AfterUpdate()
Forms!frmDEFENDANTSmain!frmPAYMENTSscreen.Requery
Forms!frmDEFENDANTSmain.Recalc
'Pause for 2 seconds
Dim t As Date
t = Now
Do While DateDiff("s", t, Now) < 2
Loop
PrintReceipts
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
DoCmd.SetWarnings False
If MsgBox("Do you want to save the change?", vbYesNo) = vbYes Then
Else
Cancel = True
End If
End Sub
Private Sub Form_Load()
Me.PartyNumber = Forms!frmDEFENDANTSmain.PartyNumber
End Sub
Private Sub Command13_Click()
'Save and Close Button
DoCmd.SetWarnings False
DoCmd.Close acForm, "frmPAYMENTentry", acSaveNo
End Sub
Private Sub PrintReceipts()
Dim BalanceLeft As Currency
Dim PaymentTotal As Currency
Dim CitationTotal As Currency
Forms!frmDEFENDANTSmain!frmCITATIONscreen!CitationTotals.Requery
Forms!frmDEFENDANTSmain!frmPAYMENTSscreen!TotalPayments.Requery
CitationTotal = Forms!frmDEFENDANTSmain!frmCITATIONscreen!CitationTotals
Debug.Print "Citation Totals " & CitationTotal
PaymentTotal = Forms!frmDEFENDANTSmain!frmPAYMENTSscreen!TotalPayments
Debug.Print "Payment Totals " & PaymentTotal
BalanceLeft = CitationTotal - PaymentTotal
Debug.Print "Balance Left " & BalanceLeft
DoCmd.OpenReport "rptPAYMENTRECEIPT", acPreview, , "PaymentID=" & Me.PaymentID
Debug.Print "Opened Receipt " & BalanceLeft
If BalanceLeft > 4.99 Then
Debug.Print "Post IF " & BalanceLeft
DoCmd.OpenReport "rptBALANCEDUE", acPreview, , "PaymentID=" &
Me.PaymentID
Debug.Print "Opened Balance Due Letter " & BalanceLeft
End If
End Sub
enter a payment, the PaymentTotal *sometimes* results in zero despite payment
existing for that account. There is no rhyme or reason for the zero result,
it is purely random. When I enter a payment, it will sometimes come up on
the 1st pmt or not at all until the 18th payment entry.
So as to understand the setup of the forms:
form frmDEFENDANTSmain = the main 'database' window. This shows the
name/address as well as the total citations and the total payment received as
well as the resulting balance.
form frmPAYMENentry = the data entry window for payments.
form frmPAYMENTSscreen = A subform (of frmDEFENDANTSmain) that shows all of
the payments.
form frmCITATIONscreen = a subform (of frmDEFENDANTSmain) that shows all of
the citations for a particular defendant.
Any help and/or suggestions would be deeply appreciated.
Option Compare Database
Private Sub Form_AfterUpdate()
Forms!frmDEFENDANTSmain!frmPAYMENTSscreen.Requery
Forms!frmDEFENDANTSmain.Recalc
'Pause for 2 seconds
Dim t As Date
t = Now
Do While DateDiff("s", t, Now) < 2
Loop
PrintReceipts
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
DoCmd.SetWarnings False
If MsgBox("Do you want to save the change?", vbYesNo) = vbYes Then
Else
Cancel = True
End If
End Sub
Private Sub Form_Load()
Me.PartyNumber = Forms!frmDEFENDANTSmain.PartyNumber
End Sub
Private Sub Command13_Click()
'Save and Close Button
DoCmd.SetWarnings False
DoCmd.Close acForm, "frmPAYMENTentry", acSaveNo
End Sub
Private Sub PrintReceipts()
Dim BalanceLeft As Currency
Dim PaymentTotal As Currency
Dim CitationTotal As Currency
Forms!frmDEFENDANTSmain!frmCITATIONscreen!CitationTotals.Requery
Forms!frmDEFENDANTSmain!frmPAYMENTSscreen!TotalPayments.Requery
CitationTotal = Forms!frmDEFENDANTSmain!frmCITATIONscreen!CitationTotals
Debug.Print "Citation Totals " & CitationTotal
PaymentTotal = Forms!frmDEFENDANTSmain!frmPAYMENTSscreen!TotalPayments
Debug.Print "Payment Totals " & PaymentTotal
BalanceLeft = CitationTotal - PaymentTotal
Debug.Print "Balance Left " & BalanceLeft
DoCmd.OpenReport "rptPAYMENTRECEIPT", acPreview, , "PaymentID=" & Me.PaymentID
Debug.Print "Opened Receipt " & BalanceLeft
If BalanceLeft > 4.99 Then
Debug.Print "Post IF " & BalanceLeft
DoCmd.OpenReport "rptBALANCEDUE", acPreview, , "PaymentID=" &
Me.PaymentID
Debug.Print "Opened Balance Due Letter " & BalanceLeft
End If
End Sub