Code:
Private Sub cmdCalculatePrem_Click()
Dim rate, rate2, rate 3 As Variant
'Get the rates for the three levels...
rate1 = CDec(DLookup("[fldRate]", "tblRates", " [fldDateLower] <= #" & Me.[Effective Date] & "# AND [fldDateUpper] >= #" & Me.[Effective Date]& "# AND [fldLevel] = 1"))
rate2 = CDec(DLookup("[fldRate]", "tblRates", " [fldDateLower] <= #" & Me.[Effective Date] & "# AND [fldDateUpper] >= #" & Me.[Effective Date] & "# AND [fldLevel] = 2"))
rate3 = CDec(DLookup("[fldRate]", "tblRates", " [fldDateLower] <= #" & Me.[Effective Date] & "# AND [fldDateUpper] >= #" & Me.[Effective Date] & "# AND [fldLevel] = 3"))
'Now calculate the three rate levels for layer 1...
Me.[Umb Prem 1_1] = ( Me.[U/L Prem 1] / Me.[U/L Mod 1] ) * rate 1 * Me.[Umb Mod 1]
Me.[Umb Prem 1_2] = ( Me.[U/L Prem 1] / Me.[U/L Mod 1] ) * rate 2 * Me.[Umb Mod 1]
Me.[Umb Prem 1_3] = ( Me.[U/L Prem 1] / Me.[U/L Mod 1] ) * rate 3 * Me.[Umb Mod 1]
End Sub
Like you said previously, the user may only want one layer, or two, or all three. Try out the code for layer 1, and if it comes out the way you want, we'll figure out a logic construct to incorporate the other two layers...
Pat
Leave a comment: