Thanks John, I changed the code and did not get any errors, so I suppose it
is working , will this stop the 00.1 error I get sometimes?.....Thanks again
Bob
Public Sub SubCalculate()
Dim dblSubTotal As Double, dblTotalAmount As Double
Dim dblWithoutDailyAmount As Double
Dim dblMonthlyChargeAmount As Double, dblAdditionChargeAmount As Double
If tbDailyChargeAmount1.value = "" Or IsNull(tbDailyChargeAmount1.value)
Then
dblWithDailyChargeAmount1 = 0
Else
dblWithDailyChargeAmount1 = Nz(tbDailyChargeAmount1)
End If
If tbDailyChargeAmount2.value = "" Or IsNull(tbDailyChargeAmount2.value)
Then
dblWithDailyChargeAmount2 = 0
Else
dblWithDailyChargeAmount2 = Nz(tbDailyChargeAmount2)
End If
If tbDailyChargeAmount3.value = "" Or IsNull(tbDailyChargeAmount3.value)
Then
dblWithDailyChargeAmount3 = 0
Else
dblWithDailyChargeAmount3 = Nz(tbDailyChargeAmount3)
End If
dblMonthlyChargeAmount = Round(Nz(DSum("MonthlyChargeAmount ",
"TmpMonthlyCharge"), 0), 2)
dblAdditionChargeAmount = Round(Nz(DSum("AdditionChargeAmount",
"TmpAdditionCharge"), 0), 2)
dblSubTotal = Round(dblMonthlyChargeAmount + dblAdditionChargeAmount +
dblWithDailyChargeAmount1 + dblWithDailyChargeAmount2 +
dblWithDailyChargeAmount3, 2)
dblWithoutDailyAmount = dblMonthlyChargeAmount + dblAdditionChargeAmount
tbSubTotal.value = dblSubTotal
If Len([cbGSTOptions]) = 0 Then
dblGSTOptionsValue = 0
dblTotalAmount = dblGSTOptionsValue + dblSubTotal
tbGSTOptionsValue.value = dblGSTOptionsValue
tbTotalAmount.value = dblTotalAmount
Exit Sub
End If
Dim recGSTOptions As New ADODB.Recordset, sngGstPercentage As Single
recGSTOptions.Open "SELECT * FROM tblGSTOptions WHERE GSTOptionsText
LIKE '" _
& cbGSTOptions.value & "'", cnnStableAccount, adOpenDynamic,
adLockOptimistic
If recGSTOptions.EOF = True And recGSTOptions.BOF = True Then
dblGSTOptionsValue = 0
dblTotalAmount = dblGSTOptionsValue + dblSubTotal
tbGSTOptionsValue.value = dblGSTOptionsValue
tbTotalAmount.value = dblTotalAmount
MsgBox "Invalid GSTOption.", vbApplicationModal + vbInformation +
vbOKOnly
Exit Sub
End If
sngGstPercentage = CSng(Nz(recGSTOptions.Fields("GSTPercentage"), 0))
If recGSTOptions.Fields("ynIncludeDaily") = True Then
dblGSTOptionsValue = (dblSubTotal * sngGstPercentage)
Else
dblGSTOptionsValue = (dblWithoutDailyAmount * sngGstPercentage)
End If
dblTotalAmount = dblGSTOptionsValue + dblSubTotal
tbGSTOptionsValue.value = dblGSTOptionsValue
tbTotalAmount.value = dblTotalAmount
Set recGSTOptions = Nothing
End Sub