A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

SubCalculate() Problem



 
 
Thread Tools Display Modes
  #1  
Old March 21st, 2010, 12:15 AM posted to microsoft.public.access
Bob Vance
external usenet poster
 
Posts: 726
Default SubCalculate() Problem


I have added 1 new field
DisPercent/Percentage/Text Box [tbDisPercent]

I am trying to get / SubTotal * Dispercent = TotalAmount

Public Sub SubCalculate()
Dim dblSubTotal As Double, dblDisPercent As Double, dblTotalAmount As
Double
Dim dblWithoutDailyAmount As Double
Dim dblMonthlyChargeAmount As Double, dblAdditionChargeAmount As Double
Dim dblWithDailyChargeAmount1 As Currency, dblGSTOptionsValue As Double
Dim dblWithDailyChargeAmount2 As Currency, dblWithDailyChargeAmount3 As
Currency
Dim dblWithDailyChargeAmount4 As Currency, dblWithDailyChargeAmount5 As
Currency, dblWithDailyChargeAmount6 As Currency

If tbDailyChargeAmount1.value = "" Or IsNull(tbDailyChargeAmount1.value)
Then
dblWithDailyChargeAmount1 = 0
Else
dblWithDailyChargeAmount1 = tbDailyChargeAmount1.value
End If

If tbDailyChargeAmount2.value = "" Or IsNull(tbDailyChargeAmount2.value)
Then
dblWithDailyChargeAmount2 = 0
Else
dblWithDailyChargeAmount2 = tbDailyChargeAmount2.value
End If

If tbDailyChargeAmount3.value = "" Or IsNull(tbDailyChargeAmount3.value)
Then
dblWithDailyChargeAmount3 = 0
Else
dblWithDailyChargeAmount3 = tbDailyChargeAmount3.value
End If

If tbDailyChargeAmount4.value = "" Or IsNull(tbDailyChargeAmount4.value)
Then
dblWithDailyChargeAmount4 = 0
Else
dblWithDailyChargeAmount4 = tbDailyChargeAmount4.value
End If
If tbDailyChargeAmount5.value = "" Or IsNull(tbDailyChargeAmount5.value)
Then
dblWithDailyChargeAmount5 = 0
Else
dblWithDailyChargeAmount5 = tbDailyChargeAmount5.value
End If
If tbDailyChargeAmount6.value = "" Or
IsNull(tbDailyChargeAmount6.value) Then
dblWithDailyChargeAmount6 = 0
Else
dblWithDailyChargeAmount6 = tbDailyChargeAmount6.value
End If



dblAdditionChargeAmount = Nz(DSum("AdditionChargeAmount",
"TmpAdditionCharge"), 0)

dblSubTotal = dblAdditionChargeAmount + _
dblWithDailyChargeAmount1 + dblWithDailyChargeAmount2 +
dblWithDailyChargeAmount3 + dblWithDailyChargeAmount4 +
dblWithDailyChargeAmount5 + dblWithDailyChargeAmount6



dblWithoutDailyAmount = dblAdditionChargeAmount

tbSubTotal.value = dblSubTotal
tbDisPercent.value = dblDisPercent


If Len([cbGSTOptions]) = 0 Then
dblGSTOptionsValue = 0
dblTotalAmount = Round((dblGSTOptionsValue + dblSubTotal), 2)
tbGSTOptionsValue.value = dblGSTOptionsValue
tbTotalAmount.value = dblTotalAmount
Exit Sub
End If

Dim recGSTOptions As New ADODB.Recordset, sngGstPercentage As Single
Set recGSTOptions = New ADODB.Recordset
recGSTOptions.Open "SELECT * FROM tblGSTOptions WHERE GSTOptionsText
LIKE '" _
& cbGSTOptions.value & "'", CurrentProject.Connection,
adOpenDynamic, adLockOptimistic

If recGSTOptions.EOF = True And recGSTOptions.BOF = True Then
dblGSTOptionsValue = 0
dblTotalAmount = Round((dblGSTOptionsValue + dblSubTotal), 2)
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 = Round((dblSubTotal * sngGstPercentage), 2) '12
Sept 2005,Pallavi
Else
dblGSTOptionsValue = Round((dblWithoutDailyAmount *
sngGstPercentage), 2) '12 Sept 2005,Pallavi
End If
dblTotalAmount = Round((dblGSTOptionsValue + dblSubTotal), 2)

tbGSTOptionsValue.value = dblGSTOptionsValue
tbTotalAmount.value = dblTotalAmount

Set recGSTOptions = Nothing
End Sub

--
Thanks in advance for any help with this......Bob
MS Access 2007 accdb
Windows XP Home Edition Ver 5.1 Service Pack 3


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 01:43 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.