Gingertrees
08-27-2008, 08:22 AM
I have a form, part of which assesses a client's financial situation. Since this is nifty information that's not widely used in many reports, all fields are unbound. Anyway, I have it set up so the user can enter client's sources of income, then hit a command button to add it (Using the ValueSum function)
-->There's got to be a better way to do this than the command button, but how? Before Update? After Update?
-->Valuesum is a long involved process, which I don't want to duplicate at least twice more for similar situations - is there a better way??
(Thanks to anyone who takes the time to look at my code.)
Private Sub Command92_Click()
'define the variables of the function
Dim value1 As Currency
Dim value2 As Currency
Dim value3 As Currency
Dim value4 As Currency
Dim value5 As Currency
Dim value6 As Currency
Dim value7 As Currency
Dim value8 As Currency
Dim value9 As Currency
Dim value10 As Currency
Dim value11 As Currency
'assign what the variables of the function stand
'for in real life for example, value1 in the
'function represents the curemployment text box
value1 = Me.curemployment.Value
'Me.WHATEVER.value = names of textboxes that
'contain values (sources of income)
value2 = Me.curspouseemployment.Value
value3 = Me.curSSI.Value
value4 = Me.curspouseSSI.Value
value5 = Me.curunemploy.Value
value6 = Me.curAFDC.Value
value7 = Me.curfoodstamps.Value
value8 = Me.curchildsupport.Value
value9 = Me.curother1.Value
value10 = Me.curother2.Value
'value11 / curtotalincome = sum of above
value11 = valuesum(value1, value2, value3,_
value4, value5, value6, value7)
Me.curtotalincome.Value = value11
End Sub
'name of the function
Function valuesum(value1 As Currency, _
value2 As Currency, value3 As Currency, _
value4 As Currency, value5 As Currency, _
value6 As Currency, value7 As Currency, _
value8 As Currency, value9 As Currency, _
value10 As Currency)
'procedure of the function
valuesum = Nz(value1, 0) + Nz(value2, 0) + _
Nz(value3, 0) + Nz(value4, 0) + Nz(value5, 0) + _
Nz(value6, 0) + Nz(value7, 0) + Nz(value8, 0) + _
Nz(value9, 0) + Nz(value10, 0)
End Function
-->There's got to be a better way to do this than the command button, but how? Before Update? After Update?
-->Valuesum is a long involved process, which I don't want to duplicate at least twice more for similar situations - is there a better way??
(Thanks to anyone who takes the time to look at my code.)
Private Sub Command92_Click()
'define the variables of the function
Dim value1 As Currency
Dim value2 As Currency
Dim value3 As Currency
Dim value4 As Currency
Dim value5 As Currency
Dim value6 As Currency
Dim value7 As Currency
Dim value8 As Currency
Dim value9 As Currency
Dim value10 As Currency
Dim value11 As Currency
'assign what the variables of the function stand
'for in real life for example, value1 in the
'function represents the curemployment text box
value1 = Me.curemployment.Value
'Me.WHATEVER.value = names of textboxes that
'contain values (sources of income)
value2 = Me.curspouseemployment.Value
value3 = Me.curSSI.Value
value4 = Me.curspouseSSI.Value
value5 = Me.curunemploy.Value
value6 = Me.curAFDC.Value
value7 = Me.curfoodstamps.Value
value8 = Me.curchildsupport.Value
value9 = Me.curother1.Value
value10 = Me.curother2.Value
'value11 / curtotalincome = sum of above
value11 = valuesum(value1, value2, value3,_
value4, value5, value6, value7)
Me.curtotalincome.Value = value11
End Sub
'name of the function
Function valuesum(value1 As Currency, _
value2 As Currency, value3 As Currency, _
value4 As Currency, value5 As Currency, _
value6 As Currency, value7 As Currency, _
value8 As Currency, value9 As Currency, _
value10 As Currency)
'procedure of the function
valuesum = Nz(value1, 0) + Nz(value2, 0) + _
Nz(value3, 0) + Nz(value4, 0) + Nz(value5, 0) + _
Nz(value6, 0) + Nz(value7, 0) + Nz(value8, 0) + _
Nz(value9, 0) + Nz(value10, 0)
End Function