3146, I know you have talked about before but....

  • Thread starter Nick 'The Database Guy'
  • Start date
N

Nick 'The Database Guy'

..... I beleive that my case is a little different.

I am getting an ODBC call fail error message when I try to run the
following code:

' This subprocedure does the manual work of adding the amount (this
can be positive or & _
negative) to the current holding
Public Function ExecuteTrade(Account As Long, NumberOfUnits As Long)
As Variant
On Error GoTo err_ExecuteTrade
Dim sql As String
Dim db As dao.Database
Dim rs As dao.Recordset
Dim lngBalance As Long
DBGcounter = DBGcounter + 1
sql = "SELECT AccountID, Holding " & _
"FROM tblAccount " & _
"WHERE AccountID = " & Account
Set db = CurrentDb()
Set rs = db.OpenRecordset(sql, dbOpenDynaset, dbSeeChanges)
With rs
.Edit
!Holding = !Holding + NumberOfUnits
.Update
ExecuteTrade = !Holding
.Close
End With

exit_ExecuteTrade:
Set rs = Nothing
db.Close
Set db = Nothing
Exit Function

err_ExecuteTrade:
If Err.Number = 3146 Then
RelinkTables
Resume
Else
ExecuteTrade = False
Resume exit_ExecuteTrade
End If

End Function

This code fails on the line "Set rs = db.OpenRecordset(sql,
dbOpenDynaset, dbSeeChanges)", when I am trying to open the record
before editing it. The mystifing thing is that it works on 53 records
before this error occurs. I have checked and the record is there,
however I can't even manually SELECT it while the code is running in
break mode, however when I stop the code it is there. Can anyone help
me? Thanks in advance if you can. Cheers
 

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