How to Insert images into a OLE Object Field

  • Thread starter Nicolae Fieraru
  • Start date
N

Nicolae Fieraru

Hi All,

I have a table with records and I want to add an image to every record.
One of the fields is an OLE Object and another is a text which contains the
image name. I want to insert an image in every record using VBA code.
I will provide the path to the images. I checked on the internet for some
sample code, but I coudn't find anything I could use.

Any help appreciated.

Regards,
Nicolae
 
L

Larry Linson

Nicolae Fieraru said:
Hi All,

I have a table with records and I want to add an image to every record.
One of the fields is an OLE Object and another is a text which contains
the
image name. I want to insert an image in every record using VBA code.
I will provide the path to the images. I checked on the internet for some
sample code, but I coudn't find anything I could use.

There is sample code with this, and a couple of other options for handling
images in Access, freely downloadable, from http://accdevel.tripod.com. If
you want to print them, too, check the printing information at MVP Stephen
Lebans' site, http://www.lebans.com.

Larry Linson
Microsoft Access MVP
 
G

Guest

Assuming you have created a form for each record, place a button on the form
called cmdAddImage with the caption Add Image and put this code in the On
Click Event. This will allow you to browse for the Image (assuming JPEGS) and
put it in the place holder on the form and consequently in your table.

Private Sub cmdAddImage_Click()
Dim dlgOpen As FileDialog

Set dlgOpen = Application.FileDialog(msoFileDialogOpen)
With dlgOpen
.AllowMultiSelect = False
.Filters.Clear
.Filters.Add "JPEG Images", "*.jpg", 1
.InitialFileName = "C:\YourPathName"
.Show
End With
If dlgOpen.SelectedItems.Count = 1 Then
YourImageBox.SourceDoc = dlgOpen.SelectedItems(1)
YourImageBox.OLETypeAllowed = acOLELinked
YourImageBox.Action = 1
End If
Set dlgOpen = Nothing
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