Solved

Using OLE To Link A Graphic Object

Posted on 2002-07-30
3
356 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
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

744 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now