
Signature
Steve Schapel, Microsoft Access MVP
On my report the below code is executed from one of the textbox controls:
Function Called from report textbox: getPremium
=IIf(IsNull([Rewrite Old Power Number]),getPremium([Bond
Amount],[UnderWriter],[is this bond void?]),IIf([Bond Amount]<=[Rewrite Bond
Amount],0,getPremium([Bond Amount],[UnderWriter],[is this bond
void?])-getPremium([Rewrite Bond Amount],[UnderWriter],[is this bond
void?])))
Function:
Public Function getPremium(ByVal BondAmount As Double, _
ByVal Underwriter As Variant, ByVal Void As Variant)
On Error GoTo HandleError
Dim returnValue As Double
'Check to see if Bond is Voided. If it is, return 0
If (Void = True) Then
returnValue = 0
GoTo theEnd
End If
Select Case loginVal
Case "jcgabb" 'John Craven General Agency
Select Case Underwriter
Case "BSC" 'South Carolina
If (BondAmount < 201) Then
returnValue = 2.5
ElseIf (201 <= BondAmount) And (BondAmount < 401) Then
returnValue = (BondAmount * 0.01) + 1
ElseIf (401 <= BondAmount) And (BondAmount < 501) Then
returnValue = 4.75
ElseIf (BondAmount >= 501) Then
returnValue = BondAmount * 0.0095
End If
Case "BNC" 'North Carolina
returnValue = (BondAmount * 0.15 * 0.063331)
Case "BTN" 'Tennesee
returnValue = (BondAmount * 0.0095)
Case "ACIC" 'American Contractors Indemnity Company
If (BondAmount <= 590) Then
returnValue = 5
Else
returnValue = (BondAmount * 0.0085)
End If
Case Else
'do nothing
*******************************
Code snipped here for brevity in group posting
*******************************
End Select
End Select
Question Continued:
My intention is to aquire the numerical values listed in the code from a
table I have created. Rather than have the hard coded values in the code
segment, I would rather call into this function these values from the table.
For another example, (BondAmount * 0.0095), I would like to aquire the value
0.0095 from a table for use in this function and do away with having 0.0095
hard coded into this function.
Thanks again for your assistance, if I need to further clarify, I will
attempt to do so.
> Box,
>
[quoted text clipped - 43 lines]
> > Thank you and if this is not clear of what I ask, I can try to explain in
> > more detail.
Steve Schapel - 22 Jan 2006 18:46 GMT
Box,
Thanks for the further clarification. However, as regards "call into
this function these values from the table", the key information here is
which table these values are in, and how does this table relate with the
data that is already in the query that the report is based on. Sorry,
can you please also try to clarify this. It may even be an idea to post
back with the SQL of the report's underlying query, and also the
relevant fields from the table that the decimal values are in.
As I mentioned before, I think the two options are to incorporate the
table with the decimal values into the report's underlying query, or
else to use DLookup function to return them into your function.

Signature
Steve Schapel, Microsoft Access MVP
> On my report the below code is executed from one of the textbox controls:
>
[quoted text clipped - 66 lines]
> Thanks again for your assistance, if I need to further clarify, I will
> attempt to do so.