P
philip260
Hello All.
please see below code. I am trying to run this vb code that will
return results of a query. The query may or may not have recordsets.
When the query does not return a result the script gives me a runtime
error 3265 (item not found in this collection). I know where the query
holds up but i figure the code i have should take care of the null.
Usually the 4th field in the query (rst.fields(4) does not have any
value and does not even return a result and the code breaks there. is
there any way to set the value to go around this error?? Thanks in
advance and please let me know if you need more information!
Set rst = CurrentDb.OpenRecordset("qry_Date Function Crosstab JP",
dbOpenSnapshot)
rst.MoveFirst
JPOutstandingDateTotal1 = 0
JPOutstandingDateTotal2 = 0
JPOutstandingDateTotal3 = 0
JPOutstandingDateTotal4 = 0
Do Until rst.EOF
If rst.Fields(0) Like "UNKNOWN" Then
If Not IsNull(rst.Fields(1)) Then
JPOutstandingDateTotal1 = JPOutstandingDateTotal1 +
rst.Fields(1)
End If
If Not IsNull(rst.Fields(2)) Then
JPOutstandingDateTotal2 = JPOutstandingDateTotal2 +
rst.Fields(2)
End If
If Not IsNull(rst.Fields(3)) Then
JPOutstandingDateTotal3 = JPOutstandingDateTotal3 +
rst.Fields(3)
End If
If Not IsNull(rst.Fields(4)) Then
JPOutstandingDateTotal4 = JPOutstandingDateTotal4 +
rst.Fields(4)
End If
Else
'do nothing
End If
rst.MoveNext
Loop
please see below code. I am trying to run this vb code that will
return results of a query. The query may or may not have recordsets.
When the query does not return a result the script gives me a runtime
error 3265 (item not found in this collection). I know where the query
holds up but i figure the code i have should take care of the null.
Usually the 4th field in the query (rst.fields(4) does not have any
value and does not even return a result and the code breaks there. is
there any way to set the value to go around this error?? Thanks in
advance and please let me know if you need more information!
Set rst = CurrentDb.OpenRecordset("qry_Date Function Crosstab JP",
dbOpenSnapshot)
rst.MoveFirst
JPOutstandingDateTotal1 = 0
JPOutstandingDateTotal2 = 0
JPOutstandingDateTotal3 = 0
JPOutstandingDateTotal4 = 0
Do Until rst.EOF
If rst.Fields(0) Like "UNKNOWN" Then
If Not IsNull(rst.Fields(1)) Then
JPOutstandingDateTotal1 = JPOutstandingDateTotal1 +
rst.Fields(1)
End If
If Not IsNull(rst.Fields(2)) Then
JPOutstandingDateTotal2 = JPOutstandingDateTotal2 +
rst.Fields(2)
End If
If Not IsNull(rst.Fields(3)) Then
JPOutstandingDateTotal3 = JPOutstandingDateTotal3 +
rst.Fields(3)
End If
If Not IsNull(rst.Fields(4)) Then
JPOutstandingDateTotal4 = JPOutstandingDateTotal4 +
rst.Fields(4)
End If
Else
'do nothing
End If
rst.MoveNext
Loop