doulostheou
Registered User.
- Local time
- Today, 00:13
- Joined
- Feb 8, 2002
- Messages
- 314
I am trying to use a few global arrays so that I do not duplicate a lot of work (if values have already been looked up, it just pulls it from the array instead of recalculating the values).
Everything works except for a very odd error the second time it passes through the array. The line that is breaking though makes no sense and the error stating the expression is too complex makes less sense. To really confuse me, if I step through the code after debug, everything works just fine. No more errors.
Here is the code with the line breaking commented:
The first function calls the second. It only breaks in case 1. Ignore some of the craziness I have there doing my math functions. It was just to try to see if I could workaround the problem (all to no avail).
I am at a loss. In one forum it said that I may need to decompile the database. But I could not get the instructions they gave to decompile to work. I'm running Access 2003 on Vista. Any suggestions would be greatly appreciated!
Everything works except for a very odd error the second time it passes through the array. The line that is breaking though makes no sense and the error stating the expression is too complex makes less sense. To really confuse me, if I step through the code after debug, everything works just fine. No more errors.
Here is the code with the line breaking commented:
Code:
Public Function compAssistant(lngCourse As Long, lngComp As Long, intStudents As Integer, curTotal As Currency) As Currency
Dim i As Integer
Dim blnFound As Boolean
If sysArrayInitialized(compArray) Then
For i = 0 To UBound(compArray, 2)
If compArray(0, i) = lngCourse Then
blnFound = True
Exit For
End If
Next i
End If
If Not blnFound Then
Call determinePay(lngCourse, lngComp, intStudents, curTotal)
For i = 0 To UBound(compArray, 2)
If compArray(0, i) = lngCourse Then
Exit For
End If
Next i
End If
compAssistant = compArray(3, i)
End Function
Public Function determinePay(lngCourse As Long, lngComp As Long, intStudents As Integer, curTotal As Currency) As Boolean
Dim i As Integer, j As Integer
Dim curInst As Currency, curAssist As Currency, curSchool As Currency, curTempTotal As Currency
If sysArrayInitialized(compArray) Then
i = UBound(compArray, 2) + 1
End If
Select Case lngComp
Case 1
If Not blnInitialized Then Call popPayArray
ReDim Preserve compArray(3, i)
For j = 0 To UBound(payArray, 2)
If payArray(0, j) <= intStudents Then
compArray(0, i) = lngCourse
curInst = payArray(1, j)
curAssist = payArray(2, j)
curSchool = payArray(3, j)
curTempTotal = curInst + curAssist + curSchool
'Code breaks on next line: Error 16. Expression too complex
curInst = CCur(CDbl(curInst) / CDbl(curTempTotal))
curAssist = CDbl(curAssist) / CDbl(curTempTotal)
curSchool = CDbl(curSchool) / CDbl(curTempTotal)
curInst = curInst * curTotal
curAssist = curAssist * curTotal
curSchool = curSchool * curTotal
compArray(1, i) = curInst
compArray(2, i) = curAssist
compArray(3, i) = curSchool
Exit For
End If
Next j
Case 2
ReDim Preserve compArray(3, i)
curInst = intStudents * 15
curTempTotal = curTotal - curInst
curAssist = 0.7 * curTempTotal
curSchool = 0.3 * curTempTotal
compArray(1, i) = curInst
compArray(2, i) = curAssist
compArray(3, i) = curSchool
Case 3
ReDim Preserve compArray(3, i)
curInst = curTotal
curAssist = 0
curSchool = 0
compArray(1, i) = curInst
compArray(2, i) = curAssist
compArray(3, i) = curSchool
End Select
End Function
The first function calls the second. It only breaks in case 1. Ignore some of the craziness I have there doing my math functions. It was just to try to see if I could workaround the problem (all to no avail).
I am at a loss. In one forum it said that I may need to decompile the database. But I could not get the instructions they gave to decompile to work. I'm running Access 2003 on Vista. Any suggestions would be greatly appreciated!