Hi,
I have converted my Access 97 database to Access 2000 and I now have a function behaving oddly. It works fine in 97 but now returns inaccurate results in 2000. Function below:
Function getLifeExceedenceList()
Dim rsEngineList, rsEngineComponent As DAO.Recordset
Dim idx, x As Integer
Dim engineList(50) As String
Dim EngineID As String
Dim exceedenceList As String
Set rsEngineList = CurrentDb.OpenRecordset("select * from engine")
idx = 1
With rsEngineList
.MoveLast
.MoveFirst
While Not .EOF
engineList(idx) = .Fields("engineId")
idx = idx + 1
.MoveNext
Wend
End With
For x = 1 To 50 '50 is an arbitary number, we will bail if we don't need that many
EngineID = engineList(x)
Set rsEngineComponent = CurrentDb.OpenRecordset("SELECT * FROM enginecomponent WHERE engineid = '" & EngineID & "'", dbOpenDynaset)
With rsEngineComponent
If .RecordCount > 0 Then
.FindFirst ("cyclesRemaining <= '" & 0 & "'")
If Not .NoMatch Then
If exceedenceList = "" Then
exceedenceList = .Fields("engineId")
Else
exceedenceList = exceedenceList & "," & .Fields("engineId")
End If
End If
.MoveFirst
.FindFirst ("hoursRemaining <= '" & 0 & "'")
If Not .NoMatch Then
If exceedenceList = "" Then
exceedenceList = .Fields("engineId")
Else
exceedenceList = exceedenceList & "," & .Fields("engineId")
End If
End If
End If
End With
Next x
getLifeExceedenceList = exceedenceList
End Function
Any help gratefully accepted.
I have converted my Access 97 database to Access 2000 and I now have a function behaving oddly. It works fine in 97 but now returns inaccurate results in 2000. Function below:
Function getLifeExceedenceList()
Dim rsEngineList, rsEngineComponent As DAO.Recordset
Dim idx, x As Integer
Dim engineList(50) As String
Dim EngineID As String
Dim exceedenceList As String
Set rsEngineList = CurrentDb.OpenRecordset("select * from engine")
idx = 1
With rsEngineList
.MoveLast
.MoveFirst
While Not .EOF
engineList(idx) = .Fields("engineId")
idx = idx + 1
.MoveNext
Wend
End With
For x = 1 To 50 '50 is an arbitary number, we will bail if we don't need that many
EngineID = engineList(x)
Set rsEngineComponent = CurrentDb.OpenRecordset("SELECT * FROM enginecomponent WHERE engineid = '" & EngineID & "'", dbOpenDynaset)
With rsEngineComponent
If .RecordCount > 0 Then
.FindFirst ("cyclesRemaining <= '" & 0 & "'")
If Not .NoMatch Then
If exceedenceList = "" Then
exceedenceList = .Fields("engineId")
Else
exceedenceList = exceedenceList & "," & .Fields("engineId")
End If
End If
.MoveFirst
.FindFirst ("hoursRemaining <= '" & 0 & "'")
If Not .NoMatch Then
If exceedenceList = "" Then
exceedenceList = .Fields("engineId")
Else
exceedenceList = exceedenceList & "," & .Fields("engineId")
End If
End If
End If
End With
Next x
getLifeExceedenceList = exceedenceList
End Function
Any help gratefully accepted.