VBA code to divide numbers for percentages

I'm using Access 2007. I have VBA code that takes a budget amount as a currency veriable and subtracts from it a sum of expenditure YTD currency variable, which works fine resulting with a budget balance remaining. I tried adding code to divide the sum variable by the budget variable, but the percent that is returned is 0.00% My table fields are currency and the form field is formated to percent. Any help to return the actual percent would be greatly appreciated.

[code]Private Sub cmdOpenBalance_Click()
DoCmd.SetWarnings False
DoCmd.OpenQuery "qryExpendStnd"
DoCmd.SetWarnings True
Dim strHoldYear As String
Dim curHoldRent As Currency
Dim curHoldFurn As Currency
Dim curHoldSecD As Currency
Dim curHoldRehb As Currency
Dim curHoldCont As Currency
Dim curSumRent As Currency
Dim curSumFurn As Currency
Dim curSumSecD As Currency
Dim curSumRehb As Currency
Dim curSumCont As Currency
DoCmd.OpenForm "frmBudget"
strHoldYear = Forms![frmBudget]![BudgetYear]
curHoldRent = Forms![frmBudget]![RentStipends]
curHoldFurn = Forms![frmBudget]![FurnitureHoushld]
curHoldSecD = Forms![frmBudget]![SecDeposit]
curHoldRehb = Forms![frmBudget]![Rehab]
curHoldCont = Forms![frmBudget]![Contingency]
DoCmd.Close acForm, "frmBudget"
DoCmd.OpenForm "frmSumRent"
curSumRent = Forms![frmSumRent]![SumOfAmount1]
DoCmd.Close acForm, "frmSumRent"
DoCmd.OpenForm "frmSumFurnHoushld"
curSumFurn = Forms![frmSumFurnHoushld]![SumOfAmount1]
DoCmd.Close acForm, "frmSumFurnHoushld"
DoCmd.OpenForm "frmSumSecDep"
curSumSecD = Forms![frmSumSecDep]![SumOfAmount1]
DoCmd.Close acForm, "frmSumSecDep"
DoCmd.OpenForm "frmSumRehab"
curSumRehb = Forms![frmSumRehab]![SumOfAmount1]
DoCmd.Close acForm, "frmSumRehab"
DoCmd.OpenForm "frmSumContin"
curSumCont = Forms![frmSumContin]![SumOfAmount1]
DoCmd.Close acForm, "frmSumContin"
DoCmd.OpenForm "frmBalance"
Forms![frmBalance]![BudgetYear] = strHoldYear
Forms![frmBalance]![RentStipends] = curHoldRent - curSumRent
Forms![frmBalance]![RentPercent] = curSumRent / curHoldRent
Forms![frmBalance]![FurnitureHoushld] = curHoldFurn - curSumFurn
Forms![frmBalance]![FurnPercent] = curSumFurn / curHoldFurn
Forms![frmBalance]![SecDeposit] = curHoldSecD - curSumSecD
Forms![frmBalance]![SecDPercent] = curSumSecD / curHoldSecD
Forms![frmBalance]![Rehab] = curHoldRehb - curSumRehb
Forms![frmBalance]![RehPercent] = curSumRehb / curHoldRehb
Forms![frmBalance]![Contingency] = curHoldCont - curSumCont
Forms![frmBalance]![ContinPercent] = curSumCont / curHoldCont

End Sub[/code]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!