ben.oates
04-16-2008, 04:33 AM
Hi all,
I have been stepping into the code below:
'Return true if it is found in the table
'This is only a superficial check. This does not mean that the whole order has been delivered.
Public Function checkDelivery(myPO As String) As Boolean
Dim rs As DAO.Recordset
On Error GoTo ErrHandler
Set rs = CurrentDb.OpenRecordset("Goods Inward-Outward", dbOpenSnapshot)
checkDelivery = False
If myPO <> "" Then
rs.FindFirst "[Purchasing PO] ='" & myPO & "'"
If rs.NoMatch Then
'Will throw exception 13 if myPO is a string
rs.FindFirst "[Standard PO] =" & CLng(myPO)
If rs.NoMatch Then
'checkDelivery = False
rs.Close
Exit Function
End If
End If
End If
checkDelivery = True
rs.Close
Exit Function
ErrHandler:
Select Case Err.Number
Case 13
'There has been a problem converting to CLng
'This is not serious and would imply that the string would not be found in the check anyway
checkDelivery = False
rs.Close
Exit Function
Case Else
'This is an unknown error - report it
raiseLog "<p>An error has occured in checkDelivery. The error number is: " & _
Err.Number & " and the description is: </p><p>" & Err.Description & _
vbCrLf & "</p><p>This is very important. This may have resulted in " & _
"the inaccurate reclassification of an ARSR.</p>", High, "Error Occured"
Resume Next
End Select
rs.Close
End Function
When exception 13 is thrown trying to convert to Long - as expected in certain instances - it goes to ErrHandler as expected, but as soon as it hits the Select Case Err.Number changes from 13 to 0. I can't work it out! Any suggestions? I've been stepping through it and can't see that I've missed anything. Very confused. :think:
Any help, as always, is greatly appreciated.
I have been stepping into the code below:
'Return true if it is found in the table
'This is only a superficial check. This does not mean that the whole order has been delivered.
Public Function checkDelivery(myPO As String) As Boolean
Dim rs As DAO.Recordset
On Error GoTo ErrHandler
Set rs = CurrentDb.OpenRecordset("Goods Inward-Outward", dbOpenSnapshot)
checkDelivery = False
If myPO <> "" Then
rs.FindFirst "[Purchasing PO] ='" & myPO & "'"
If rs.NoMatch Then
'Will throw exception 13 if myPO is a string
rs.FindFirst "[Standard PO] =" & CLng(myPO)
If rs.NoMatch Then
'checkDelivery = False
rs.Close
Exit Function
End If
End If
End If
checkDelivery = True
rs.Close
Exit Function
ErrHandler:
Select Case Err.Number
Case 13
'There has been a problem converting to CLng
'This is not serious and would imply that the string would not be found in the check anyway
checkDelivery = False
rs.Close
Exit Function
Case Else
'This is an unknown error - report it
raiseLog "<p>An error has occured in checkDelivery. The error number is: " & _
Err.Number & " and the description is: </p><p>" & Err.Description & _
vbCrLf & "</p><p>This is very important. This may have resulted in " & _
"the inaccurate reclassification of an ARSR.</p>", High, "Error Occured"
Resume Next
End Select
rs.Close
End Function
When exception 13 is thrown trying to convert to Long - as expected in certain instances - it goes to ErrHandler as expected, but as soon as it hits the Select Case Err.Number changes from 13 to 0. I can't work it out! Any suggestions? I've been stepping through it and can't see that I've missed anything. Very confused. :think:
Any help, as always, is greatly appreciated.