Solved

Using OLE To Link A Graphic Object

Posted on 2002-07-30
3
403 Views
Last Modified: 2008-03-17
Greetings;

I have an Access database whereby the user selects a file of extension .gif or .jpg listed in an unbound control to be linked to a bound field of type OLE Object (Picture_Image). I am using the following code for the double-click event of the file list (The Picture_File_Name is a bound field which holds the relative path to where the .jpg or .gif file exists):

Private Sub lstFiles_DblClick(Cancel As Integer)
    Dim strFileSelected As String
    Dim strFilePath As String

    strFileSelected = lstFiles.Value
    Picture_File_Name.Value = strFileSelected
    strFilePath = "C:\Documents and Settings\Dave Stolzenbach\My Documents\PBP Clients\Lawrence Technologies\catalog_pictures\" + strFileSelected
    Picture_Image.OLETypeAllowed = 0
    Picture_Image.SourceDoc = strFilePath
    Picture_Image.SourceItem = ???
End Sub

The examples for .SourceItem in Access help and MSDN Library use Excel which isn't helping me much. I need to know what value is expected for .SourceItem for .jpg and .gif files.

Any help on this is greatly appreciated.


Much thanks.

Dave Stolzenbach
Owner
ParkerBach Pages
www.parkerbach.com
1-800-421-1488
Mobile: 1-925-408-6744
Fax: 1-925-825-9450
Email: Dave@ParkerBach.com
Member of the
   Golden Gate Better Business Bureau
   www.GoldenGateBBB.org
0
Comment
Question by:David Bach
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 28

Expert Comment

by:TextReport
ID: 7188555
I do this with an OLEImage rather than an Unbound Object Frame and you just have to specify the Picture property.

The Following code is called from my OnCurrent event

Private Function DisplayImage()
Application.Echo False
DoCmd.Hourglass True
On Error GoTo DisplayImage_error
    If IsNull(Me.txtCalendarPhoto) Then
       Me.oleImage.Picture = ""
    Else
       Me.oleImage.Picture = DEFAULTPATH & Me.txtCalendarPhoto
    End If
   
    If IsNull(Me.txtCalendarPhoto2) Then
       Me.oleImage2.Visible = False
       Me.oleImage2.Picture = ""
       Me.oleImage.Width = Me.oleImage2.Left + Me.oleImage2.Width
    Else
       Me.oleImage2.Visible = True
       Me.oleImage2.Picture = DEFAULTPATH & Me.txtCalendarPhoto2
       Me.oleImage.Width = Me.oleImage2.Width
    End If

DisplayImage_Exit:
    DoCmd.Hourglass False
    Application.Echo True
    Exit Function
   
DisplayImage_error:
    Select Case Err
        Case Else
             MsgBox "An unexpected error hass occourred in DisplayImage" & vbCrLf & vbCrLf & Err & vbTab & Err.Description, vbCritical
             Resume DisplayImage_Exit
    End Select
End Function

Cheers, Andrew
0
 
LVL 54

Expert Comment

by:nico5038
ID: 7286165

No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
 - PAQ'd and pts removed
Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

Nic;o)
0
 

Accepted Solution

by:
ComTech earned 0 total points
ID: 7314799
This question will be placed in PAQ and points refunded.

Best regards,
ComTech
Community Support
Administrator @ EE
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question