magi
Jul 16th, 1999, 01:51 PM
:( In my program I find for a particular substring in some fields of a MsAccess DataBase.
When the string is not found , the error trap tells me that the program has found no record and I can go on with the program.
This is a sample of the code
Function trova_schede(datacrl As Data, cond As String, ordine As String) As Integer
.....
On Error GoTo err_trova_schede
...
...
q$ = "SELECT DISTINCTROW " + c$ + " FROM ((autori INNER JOIN schede On autori.autore_id= schede.autore_id)"
q$ = q$ + " LEFT JOIN esposizioni ON schede.exp_id = esposizioni.exp_id)"
q$ = q$ + " WHERE " + cond$ + ord$
datacrl.RecordSource = q$
datacrl.Refresh
datacrl.Recordset.MoveLast
datacrl.Recordset.MoveFirst
trova_schede = datacrl.Recordset.RecordCount
exit_trova_schede:
Exit Function
err_trova_schede:
If Err = 3021 Then 'non current record
trova_schede = 0
Resume exit_trova_schede
Else
Beep
MsgBox (Error$)
End If
End Function
Running this code at design time from Visual Basic works fine while running the same compiled program I get the error 3021(no current record) and the program stops.
Generally: why a program if compiled behaviours differently in trapping errors?
[This message has been edited by magi (edited 07-18-1999).]
[This message has been edited by magi (edited 07-18-1999).]
When the string is not found , the error trap tells me that the program has found no record and I can go on with the program.
This is a sample of the code
Function trova_schede(datacrl As Data, cond As String, ordine As String) As Integer
.....
On Error GoTo err_trova_schede
...
...
q$ = "SELECT DISTINCTROW " + c$ + " FROM ((autori INNER JOIN schede On autori.autore_id= schede.autore_id)"
q$ = q$ + " LEFT JOIN esposizioni ON schede.exp_id = esposizioni.exp_id)"
q$ = q$ + " WHERE " + cond$ + ord$
datacrl.RecordSource = q$
datacrl.Refresh
datacrl.Recordset.MoveLast
datacrl.Recordset.MoveFirst
trova_schede = datacrl.Recordset.RecordCount
exit_trova_schede:
Exit Function
err_trova_schede:
If Err = 3021 Then 'non current record
trova_schede = 0
Resume exit_trova_schede
Else
Beep
MsgBox (Error$)
End If
End Function
Running this code at design time from Visual Basic works fine while running the same compiled program I get the error 3021(no current record) and the program stops.
Generally: why a program if compiled behaviours differently in trapping errors?
[This message has been edited by magi (edited 07-18-1999).]
[This message has been edited by magi (edited 07-18-1999).]