Hi,
I need some urgent help.
I have four fields, txtAmount and txtBalance whcih are both unbound and formatted as currency. The txtAmount is populated by the user when they select an account from a drop down list. The txtBalance holds the balance after the calculation is made.
The other two fields, are in my BDAPayments table, PreAmt and RMBAmt. The user enters the amounts for these fields. The formats are currency for both and the decimal place is set at two.
Here is the code i'm using. I would really appreciate some assistance with this.
Function AmountAwarded(BDAAccID As Integer) As Long
Dim rst As DAO.Recordset
Dim db As Database
Set db = CurrentDb()
Set rst = db.OpenRecordset("BDA Allocations", dbOpenDynaset)
AmountAwarded = 0
Do Until rst.EOF
If rst!BDAAccID = BDAAccID Then
AmountAwarded = rst!Amount
Exit Do
End If
rst.MoveNext
Loop
rst.Close
End Function
Function Balance(BDAAccID As Integer) As Long
Dim rst As DAO.Recordset
Dim db As Database
Dim I, sumRec As Integer
Dim AmountAwarded As Long
Set db = CurrentDb()
Set rst = db.OpenRecordset("BDA Allocations", dbOpenDynaset)
AmountAwarded = 0
Do Until rst.EOF
If rst!BDAAccID = BDAAccID Then
AmountAwarded = rst!Amount
Exit Do
End If
rst.MoveNext
Loop
rst.Close
Balance = AmountAwarded
Set db = CurrentDb()
Set rst = db.OpenRecordset("BDA Payments", dbOpenDynaset)
Do Until rst.EOF
If rst!BDAAccID = BDAAccID Then
If IsNull(rst!RmbAmt) Then
With rst
.Edit
rst!RmbAmt = 0
.Update
End With
End If
If IsNull(rst!PreAmt) Then
With rst
.Edit
rst!PreAmt = 0
.Update
End With
End If
Balance = Balance - IIf(rst!RmbAmt = 0, rst!PreAmt, rst!RmbAmt)
End If
rst.MoveNext
Loop
rst.Close
End Function
Thank you,
Tess
I need some urgent help.
I have four fields, txtAmount and txtBalance whcih are both unbound and formatted as currency. The txtAmount is populated by the user when they select an account from a drop down list. The txtBalance holds the balance after the calculation is made.
The other two fields, are in my BDAPayments table, PreAmt and RMBAmt. The user enters the amounts for these fields. The formats are currency for both and the decimal place is set at two.
Here is the code i'm using. I would really appreciate some assistance with this.
Function AmountAwarded(BDAAccID As Integer) As Long
Dim rst As DAO.Recordset
Dim db As Database
Set db = CurrentDb()
Set rst = db.OpenRecordset("BDA Allocations", dbOpenDynaset)
AmountAwarded = 0
Do Until rst.EOF
If rst!BDAAccID = BDAAccID Then
AmountAwarded = rst!Amount
Exit Do
End If
rst.MoveNext
Loop
rst.Close
End Function
Function Balance(BDAAccID As Integer) As Long
Dim rst As DAO.Recordset
Dim db As Database
Dim I, sumRec As Integer
Dim AmountAwarded As Long
Set db = CurrentDb()
Set rst = db.OpenRecordset("BDA Allocations", dbOpenDynaset)
AmountAwarded = 0
Do Until rst.EOF
If rst!BDAAccID = BDAAccID Then
AmountAwarded = rst!Amount
Exit Do
End If
rst.MoveNext
Loop
rst.Close
Balance = AmountAwarded
Set db = CurrentDb()
Set rst = db.OpenRecordset("BDA Payments", dbOpenDynaset)
Do Until rst.EOF
If rst!BDAAccID = BDAAccID Then
If IsNull(rst!RmbAmt) Then
With rst
.Edit
rst!RmbAmt = 0
.Update
End With
End If
If IsNull(rst!PreAmt) Then
With rst
.Edit
rst!PreAmt = 0
.Update
End With
End If
Balance = Balance - IIf(rst!RmbAmt = 0, rst!PreAmt, rst!RmbAmt)
End If
rst.MoveNext
Loop
rst.Close
End Function
Thank you,
Tess