Friday, April 7, 2017

Access VBA- To Insert Pictures in Form From an External Source

Steps:
  1. Create a table with Photo column with filepath of the pictures. The Photo column is TEXT datatype.
  2. Populate the table with pictures path.
  3. Create a form using this table.
  4. Insert an image control on the form in design view.
  5. Cancel the insert image instruction.
  6. Double click the form to open its property dialog box.
  7. In the Event tab of property sheet, double click the ellipsis for "on current" event.
  8. Paste the below code.
  9. Use the Picture property of the image control to pass the file path of the photo location.
  10. The following code in the Form event subroutine can do this :)
Note: On Current event of form happens when record is changed and for the current record, event occurs.

Option Compare Database
Option Explicit

Private Sub Form_Current()
    If Photo <> "" Then
        Me.ImagePerson.Picture = Photo
    End If
End Sub








No comments:

Post a Comment

Hot Topics