Comparing Amounts

  • Thread starter Thread starter DBarker
  • Start date Start date
D

DBarker

Below is the code, I do not know if I have done this
properly or not. It is not working. Any help would be
appreciated.

Thanks,
Debbie
----------------------------------------------------------

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim Amount As Currency
Dim Total As Currency

Total_Amount = Total
Forms![Invoice_Detail_Subform]![TotalAmount] = Amount

If Total = Amount Then
DoCmd.FindNext

Else

MsgBox "Please check your amounts they do not equal the
amount of the total invoice"
End If



End Sub
 
Below is the code, I do not know if I have done this
properly or not. It is not working. Any help would be
appreciated.

Thanks,
Debbie
----------------------------------------------------------

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim Amount As Currency
Dim Total As Currency

Total_Amount = Total

So you're defining a variable named Total, not setting it to anything
so that it will probably be equal to zero, and then setting... what? a
variable? a form control?... equal to that zero...
Forms![Invoice_Detail_Subform]![TotalAmount] = Amount

and then setting a form control equal to another undefined variable...
If Total = Amount Then

and comparing the two undefined variables to see if they are equal
(they probably will be...)
DoCmd.FindNext

and your finding the next... what? No criteria?
Else

MsgBox "Please check your amounts they do not equal the
amount of the total invoice"
End If



End Sub

In other words, I can't even figure out what this function is designed
to accomplish, and it's almost certainly NOT going to work.
 
OK, I will try to explain this.

I have a main form and on the header of that form they
enter the total of the invoice. On the same form I have
a subform where they can distribute that total amount to
different accounts. So the subform can have multiple
entries for that one invoice. Now before they move to
the next invoice to enter I want to compare the total
amount of the invoice to the sum of the detailed amounts
entered to make sure that they equal.

Sorry for the confusion.
-----Original Message-----
Below is the code, I do not know if I have done this
properly or not. It is not working. Any help would be
appreciated.

Thanks,
Debbie
-------------------------------------------------------- --

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim Amount As Currency
Dim Total As Currency

Total_Amount = Total

So you're defining a variable named Total, not setting it to anything
so that it will probably be equal to zero, and then setting... what? a
variable? a form control?... equal to that zero...
Forms![Invoice_Detail_Subform]![TotalAmount] = Amount

and then setting a form control equal to another undefined variable...
If Total = Amount Then

and comparing the two undefined variables to see if they are equal
(they probably will be...)
DoCmd.FindNext

and your finding the next... what? No criteria?
Else

MsgBox "Please check your amounts they do not equal the
amount of the total invoice"
End If



End Sub

In other words, I can't even figure out what this function is designed
to accomplish, and it's almost certainly NOT going to work.


.
 
Never Mind I figured this out this morning, thank you
anyway.
-----Original Message-----
OK, I will try to explain this.

I have a main form and on the header of that form they
enter the total of the invoice. On the same form I have
a subform where they can distribute that total amount to
different accounts. So the subform can have multiple
entries for that one invoice. Now before they move to
the next invoice to enter I want to compare the total
amount of the invoice to the sum of the detailed amounts
entered to make sure that they equal.

Sorry for the confusion.
-----Original Message-----
-
--
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim Amount As Currency
Dim Total As Currency

Total_Amount = Total

So you're defining a variable named Total, not setting it to anything
so that it will probably be equal to zero, and then setting... what? a
variable? a form control?... equal to that zero...
Forms![Invoice_Detail_Subform]![TotalAmount] = Amount

and then setting a form control equal to another undefined variable...
If Total = Amount Then

and comparing the two undefined variables to see if
they
are equal
(they probably will be...)


and your finding the next... what? No criteria?


In other words, I can't even figure out what this function is designed
to accomplish, and it's almost certainly NOT going to work.


.
.
 
Back
Top