mkasson
Programmer
- Jan 3, 2004
- 36
I have functions in a report module and Access says it is not finding certain fields. The functions return #error without error trapping. The Err.Description is "Lien Database can't find the field 'OrigAmt' referred to in you expression." The report's control source includes all of the neccesary fields (SELECT Liens.*, * FROM Liens.
Below is one of the functions:
I saw in Thread 703-757058 an indication by Steve101 that reference can't be made to fields from the control source that are not included as a bound field on the report.
When I added bound fields for all the fields from the field selector, the functions work fine. I did notice that the bound fields had/have the same name as the db field if that points to anything.
Each record in my database has about 40 numbers and dates used for calculation and I would hate to have to keep putting them in every report, even if they are invisible.
Is there a better way?
Thanks.
- MSK
Below is one of the functions:
Code:
Public Function CalcBal(evalDate As Date) As Double
Dim Penalty As Double
On Error GoTo Err_CalcBal
If evalDate = -1 Then
evalDate = Date
End If
'Determine penalty per NJSA 54:5-61
Penalty = 0
Select Case Nz([OrigAmt])
Case Is > 10000
Penalty = 0.06
Case Is > 5000
Penalty = 0.04
Case Is > 200
Penalty = 0.02
End Select
' Includes recording, search and penalty; NEEDS LEGAL
CalcBal = Nz([OrigAmt]) * (1 + Nz([OrigRate]) * (evalDate - Nz([OrigDate])) / 365) _
+ 29 + Nz([OrigAmt]) * Penalty _
+ Nz([S1Amt]) * (1 + 0.18 * (evalDate - Nz([S1Date])) / 365) _
+ Nz([S2Amt]) * (1 + 0.18 * (evalDate - Nz([S2Date])) / 365) _
+ Nz([S3Amt]) * (1 + 0.18 * (evalDate - Nz([S3Date])) / 365) _
+ Nz([S4Amt]) * (1 + 0.18 * (evalDate - Nz([S4Date])) / 365) _
+ Nz([S5Amt]) * (1 + 0.18 * (evalDate - Nz([S5Date])) / 365) _
+ Nz([S6Amt]) * (1 + 0.18 * (evalDate - Nz([S6Date])) / 365) _
+ Nz([S7Amt]) * (1 + 0.18 * (evalDate - Nz([S7Date])) / 365) _
+ Nz([S8Amt]) * (1 + 0.18 * (evalDate - Nz([S8Date])) / 365) _
+ Nz([S9Amt]) * (1 + 0.18 * (evalDate - Nz([S9Date])) / 365) _
+ Nz([S10Amt]) * (1 + 0.18 * (evalDate - Nz([S10Date])) / 365) _
+ Nz([S11Amt]) * (1 + 0.18 * (evalDate - Nz([S11Date])) / 365) _
+ Nz([S12Amt]) * (1 + 0.18 * (evalDate - Nz([S12Date])) / 365) _
+ Nz([S13Amt]) * (1 + 0.18 * (evalDate - Nz([S13Date])) / 365) _
+ Nz([S14Amt]) * (1 + 0.18 * (evalDate - Nz([S14Date])) / 365) _
+ Nz([S15Amt]) * (1 + 0.18 * (evalDate - Nz([S15Date])) / 365) _
+ Nz([S16Amt]) * (1 + 0.18 * (evalDate - Nz([S16Date])) / 365)
Exit_CalcBal:
Exit Function
Err_CalcBal:
MsgBox Err.Description
Resume Exit_CalcBal
End Function
I saw in Thread 703-757058 an indication by Steve101 that reference can't be made to fields from the control source that are not included as a bound field on the report.
When I added bound fields for all the fields from the field selector, the functions work fine. I did notice that the bound fields had/have the same name as the db field if that points to anything.
Each record in my database has about 40 numbers and dates used for calculation and I would hate to have to keep putting them in every report, even if they are invisible.
Is there a better way?
Thanks.
- MSK