Save Image

D

Dan @BCBS

I do not understand why I am getting a read only when I run this code.


Private Sub cmdSave_Click()
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![frmImageBLOBSummaryList].Requery
DoCmd.Echo False
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