Table Update ODBC

D

Dan @BCBS

Cannot understand why I keep getting Error 3146: ODBC--call failed. in Sub
cmdSave_Click

Situation: The form has a command button with the below code attached.
When clicked it should save the current data to table "tblImageBLOBs".
The table is connected by ODBC to an SQL table. Why the breakdown happens -
I cannot figure - any suggestions???



Private Sub cmdSave_Click()
' Purpose : To save the record with identification and image file
On Error GoTo Err_cmdSave_Click
Dim vntRetVar As Variant
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb()
Set rs = db.OpenRecordset("tblImageBLOBs")
'If Validated, Save; if not, just return to Form
If Validate Then
vntRetVar = ReadBLOB(Me![imgTheImage].Picture, rs, "ImageItem")
If vntRetVar <= 0 Then GoTo SpecialError
rs.MoveLast
rs.Edit
rs("ImageShortName") = Me![txtImageShortName]
rs("ImageName") = Me![txtImageName]
rs("ImageFileExtension") = Right(Me![imgTheImage].Picture, 3)
rs.Update
On Error Resume Next
DoCmd.Echo False
Forms![f_TrackingData].Requery
DoCmd.Echo True
DoCmd.Close acForm, Me.Name
End If
Exit_cmdSave_Click:
On Error Resume Next
rs.Close
Set rs = Nothing
Set db = Nothing
Exit Sub
Err_cmdSave_Click:
MsgBox "Err: " & Err.Number & " : " & Err.Description & _
" in Sub cmdSave_Click", vbCritical, "Images in Access Example"
Resume Exit_cmdSave_Click
SpecialError:
MsgBox "Error " & -vntRetVar & " trying to write the BLOB",
vbExclamation, "Images in Access Example"
Resume Exit_cmdSave_Click
End 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