USING INSERT INTO TO ADD IMAGE TO TABLE

Eze Ukaoha
Eze Ukaoha used Ask the Experts™
on
Currentdb.Execute "INSERT INTO tblRegister(Surname,FirstName,MiddleName,Email,UserName,Password,ComfirmPassword,SecurityLevel,MobilePhoneNo,HomePhone,DateofBirth,Gender,MaritalStatus,NumberofChildren,Occupation,HomeAddress,StateofOrigin,Nationality)" & _
    " VALUES('" & Me.txtSurname.Value & "','" & Me.txtFName.Value & "','" & Me.txtMName.Value & "','" & Me.txtEmail.Value & "','" & _
Me.txtUsername.Value & "','" & Me.txtPassword.Value & "','" & Me.txtPasswordConfirm.Value & "','" & Me.cmbSecurityLevel.Value & "','" & _
Me.txtMobileNo.Value & "','" & Me.txtHomePhone & "','" & Me.txtDOB.Value & "','" & Me.cmbGender.Value & "','" & Me.cmbMaritalStatus.Value & "','" & Me.txtchildren.Value & "','" & _
Me.txtOccupation.Value & "','" & Me.txtAddress.Value & "','" & Me.State.Value & "','" & Me.txtNationality.Value & "')"

Above code is used to insert into table. Now, I have a field in the tblRegister named image. How can I insert the image into the field image together with other records when I clicked the button save. I have already added a filedialog that adds image to the form. Just want to insert the image to table by clicking the insert button
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Software & Systems Engineer
Commented:
You can use this code to store the Image as Blob
Private Sub StoreImage()
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("tblRegister")
With rst
.AddNew
.Fields("Image) = Me.ImageControl.PictureData
.Update
End With
set rst = Nothing
End Sub

Open in new window


To read it back
Private Sub RetrieveImage()
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("tblRegister")
 Me.ImageControl.PictureData = rst.Fields("Image").Value
Set rst = Nothing
End Sub

Open in new window

Author

Commented:
Where do I put the code? inside the current button or should I create another button?
John TsioumprisSoftware & Systems Engineer

Commented:
This up to you...normally you want to press 1 button to do all the job so add the method at the end of the click event..but you need to filter the recordset to point to the new record
John TsioumprisSoftware & Systems Engineer

Commented:
Solution provided

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial