Hi LB -
Well, it's been roundabout getting to this point, but I think your explanation about how the calculation works really clarifies matters nicely.
So, you have text boxes on your form that the user enters numbers into:
[U/L Prem]
[U/L Mod]
[Umb Mod]
[Effective Date]
And the idea is that three other text boxes, one for each level, will be filled in according to those four pieces of data after clicking a command button (which I have called "cmdCalculatePr em"):
[Umb Prem 1]
[Umb Prem 2]
[Umb Prem 3]
If I'm reading the stages of your calculation correctly, it looks like
[Umb Prem 1] = 0.09*[U/L Prem]*[U/L Mod]*[Umb Mod]
and similarly for the other two levels. In the On Click event for the command button, we could do something like this:
This will be dependent on having values in all of the input boxes; if you want to ensure that there are values in all the boxes before the user clicks the calculate button, there are many ways of doing that and we could discuss it after getting this basic part of it working.
Let me know what you think.
Pat
Well, it's been roundabout getting to this point, but I think your explanation about how the calculation works really clarifies matters nicely.
So, you have text boxes on your form that the user enters numbers into:
[U/L Prem]
[U/L Mod]
[Umb Mod]
[Effective Date]
And the idea is that three other text boxes, one for each level, will be filled in according to those four pieces of data after clicking a command button (which I have called "cmdCalculatePr em"):
[Umb Prem 1]
[Umb Prem 2]
[Umb Prem 3]
If I'm reading the stages of your calculation correctly, it looks like
[Umb Prem 1] = 0.09*[U/L Prem]*[U/L Mod]*[Umb Mod]
and similarly for the other two levels. In the On Click event for the command button, we could do something like this:
Code:
Private Sub cmdCalculatePrem_Click()
Dim dteEffectiveDate As Date
Dim rate, rate2, rate 3 As Variant
dteEffectiveDate = CDate(Me.[Effective Date])
'Get the rates for the three levels...
rate1 = CDec(DLookup("[fldRate]", "tblRates", " [fldDateLower] <= #" & dteEffectiveDate & "# AND [fldDateUpper] >= #" & dteEffectiveDate & "# AND [fldLevel] = 1"))
rate2 = CDec(DLookup("[fldRate]", "tblRates", " [fldDateLower] <= #" & dteEffectiveDate & "# AND [fldDateUpper] >= #" & dteEffectiveDate & "# AND [fldLevel] = 2"))
rate3 = CDec(DLookup("[fldRate]", "tblRates", " [fldDateLower] <= #" & dteEffectiveDate & "# AND [fldDateUpper] >= #" & dteEffectiveDate & "# AND [fldLevel] = 3"))
'Now calculate the three respective premiums...
Me.[Umb Prem 1] = rate1*[U/L Prem]*[U/L Mod]*[Umb Mod]
Me.[Umb Prem 2] = rate2*[U/L Prem]*[U/L Mod]*[Umb Mod]
Me.[Umb Prem 3] = rate3*[U/L Prem]*[U/L Mod]*[Umb Mod]
End Sub
This will be dependent on having values in all of the input boxes; if you want to ensure that there are values in all the boxes before the user clicks the calculate button, there are many ways of doing that and we could discuss it after getting this basic part of it working.
Let me know what you think.
Pat
Comment