Error 3167

P

Paul fpvt2

In VB6, we access data from Access97 using the Data
control. Sometimes, we get error 3167 (Record is deleted).
If we close the program and try again, the error does not
appear again. I don't think the record is deleted when
the error happens. There are many articles about this
error, but I have not found one with Data control. How
can I fix this problem ?
Thanks.

Here are part of the codes:

on error goto err
Data1.DatabaseName = "\\servername\dbdir\myDB.mdb"
Data1.RecordSource = "SELECT colA FROM query1 where colB
= 'CHICAGO'"
Data1.Refresh
Do While Data1.Recordset.EOF = False
sColA = Data1.Recordset("colA")
Data1.Recordset.MoveNext
Loop
Exit Sub

Err:
msgbox " LoadQuotes - err = " & Err & " ; error = " &
Error
Exit Sub
 
J

Jim Carlock

I'll take a stab at this, but I don't know if this is the proper
fix to your solution. I see a couple things wrong with your
error handling.

I'm thinking along the lines that there are ALOT of different
Error objects. The code you presented below indicates that
you are using an unreferenced Error object.

1) On Error Goto Err
That is improper. Err is an object in the VB environment.
You should consider renaming it to something like:

Private Sub ElementID()
On Error Goto ElementIDErr
'... code
End Sub

2) The following line is the one using the unreferenced
Error object:
msgbox " LoadQuotes - err = " & Err & " ; error = " & Error

It should read:
MsgBox " LoadQuotes - Err = " & CStr(Err.Number) & vbCrLf & Err.Description

What I mean about Error being unreferenced:

ADODB.Error.Description
DAO.Error.Description
WinSock.Error.Description

Now which Error object are you involved with? And will
ADODB.Error(3167).Description be the same as
DAO.Error(3167).Description ?

There seem to be quite a few other Error objects around as
well. If you have your own controls that you are using, those
controls might have their own Error object as well.

I'd start by fixing those two things and see if that helps. Let
us know.

--
Jim Carlock
Post replies to newsgroup.

In VB6, we access data from Access97 using the Data
control. Sometimes, we get error 3167 (Record is deleted).
If we close the program and try again, the error does not
appear again. I don't think the record is deleted when
the error happens. There are many articles about this
error, but I have not found one with Data control. How
can I fix this problem ?
Thanks.

Here are part of the codes:

on error goto err
Data1.DatabaseName = "\\servername\dbdir\myDB.mdb"
Data1.RecordSource = "SELECT colA FROM query1 where colB
= 'CHICAGO'"
Data1.Refresh
Do While Data1.Recordset.EOF = False
sColA = Data1.Recordset("colA")
Data1.Recordset.MoveNext
Loop
Exit Sub

Err:
msgbox " LoadQuotes - err = " & Err & " ; error = " &
Error
Exit Sub
 
J

Jim Carlock

Oops, I left out some things. The code I posted for (1):

Private Sub ElementID()
On Error Goto ElementIDErr
'... code
End Sub

Should read more like:

Public sErrHead As String
sErrHead = "Error # "

Private Sub ElementID()
On Error GoTo ElementIDErr
'...code
Exit Sub
ElementIDErr:
MsgBox sErrHead & CStr(Err.Number) & vbCrLf & Err.Description
End Sub

Also, I see some websites using Error(Err) to display an
error description, and I hate assuming things. That may
work fine, but I'm going to suggest AVOID using it. Stick
with the Err object to get your errors.

As far as the error message goes, do multiple people have
the same .mdb file open at the same time? And rather than
assume that your Data1 is ADODB it would be helpful if
you stated that Data1 IS ADODB or IS DAO. I'm stating
this because I think there used to be and still are some
DAO data controls used in different places, but I could be
wrong.

Hope that helps.

--
Jim Carlock
Post replies to newsgroup.


:
I'll take a stab at this, but I don't know if this is the proper
fix to your solution. I see a couple things wrong with your
error handling.

I'm thinking along the lines that there are ALOT of different
Error objects. The code you presented below indicates that
you are using an unreferenced Error object.

1) On Error Goto Err
That is improper. Err is an object in the VB environment.
You should consider renaming it to something like:

Private Sub ElementID()
On Error Goto ElementIDErr
'... code
End Sub

2) The following line is the one using the unreferenced
Error object:
msgbox " LoadQuotes - err = " & Err & " ; error = " & Error

It should read:
MsgBox " LoadQuotes - Err = " & CStr(Err.Number) & vbCrLf & Err.Description

What I mean about Error being unreferenced:

ADODB.Error.Description
DAO.Error.Description
WinSock.Error.Description

Now which Error object are you involved with? And will
ADODB.Error(3167).Description be the same as
DAO.Error(3167).Description ?

There seem to be quite a few other Error objects around as
well. If you have your own controls that you are using, those
controls might have their own Error object as well.

I'd start by fixing those two things and see if that helps. Let
us know.

--
Jim Carlock
Post replies to newsgroup.

In VB6, we access data from Access97 using the Data
control. Sometimes, we get error 3167 (Record is deleted).
If we close the program and try again, the error does not
appear again. I don't think the record is deleted when
the error happens. There are many articles about this
error, but I have not found one with Data control. How
can I fix this problem ?
Thanks.

Here are part of the codes:

on error goto err
Data1.DatabaseName = "\\servername\dbdir\myDB.mdb"
Data1.RecordSource = "SELECT colA FROM query1 where colB
= 'CHICAGO'"
Data1.Refresh
Do While Data1.Recordset.EOF = False
sColA = Data1.Recordset("colA")
Data1.Recordset.MoveNext
Loop
Exit Sub

Err:
msgbox " LoadQuotes - err = " & Err & " ; error = " &
Error
Exit Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top