Subscript out of range?? (1 Viewer)

L4serK!LL

Registered User.
Local time
Today, 23:54
Joined
Jul 22, 2002
Messages
59
Code:
    Set rst = CurrentDb.OpenRecordset("BonZoek")
    With rst
        '.Filter = "Leveringsbon=" & Bon
        varItem = .GetRows()
        
        For intIRow = 1 To .RecordCount
            If (varItem(0, intIRow - 1) = Bon) Then strWhere = strWhere & ", " & varItem(1, intIRow - 1)
        Next intIRow
    End With
gives me "subscript out of range" with the second loop while the table has 3 rows which I'm sure of... :(

How to get rid of this bug? :confused:


TIA
 
Try a Debug.print of the recordcount. If it returns zero rows, do
.Move Last
.MoveFirst

after opening the recordset, to make sure that the correct number of rows is returned.
 
Thanks, the movelast + movefirst manoeuvre works just perfectly! :D
I'd never think of that :rolleyes:
 

Users who are viewing this thread

Back
Top Bottom