Results 1 to 8 of 8
  1. #1
    Join Date
    Feb 2004
    Posts
    214

    Unanswered: OnClick function and inserting OLE object

    I have an OLE field that will store a jpg image. Is there a way in vb to open the insert OLE object window when the user click a particular command button or field?
    You know, I'm sick of following my dreams, man. I'm just going to ask where they're going and hook up with 'em later

  2. #2
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    My head is screaming "don't do it".

    OLE fields are the scourge of healthy database files.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  3. #3
    Join Date
    Feb 2004
    Posts
    214

    what if...

    What if I am using OLE fields as links to jpg files as opposed actually inserting the files? I know most of the concerns with OLE in a table, but this db will be small housing anywhere from 200-500 records only.

    If I have a field with the location of the original file that I want to link, is there an easy way to do this? I have tried the following code, but I missing some elements. I have never messed with OLE objects so I have no idea where to start with the code.

    Private Sub Document_Click()
    Me.Document.OLETypeAllowed = acOLELinked
    Me.Document.SourceDoc = Me.Location
    End Sub
    You know, I'm sick of following my dreams, man. I'm just going to ask where they're going and hook up with 'em later

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    would it not be easier to put an image control on the form or report and assign the location of the file tot he image control at run time?
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Feb 2004
    Posts
    214

    ...

    Healdem, do you have an example.
    You know, I'm sick of following my dreams, man. I'm just going to ask where they're going and hook up with 'em later

  6. #6
    Join Date
    Feb 2004
    Posts
    214

    Would this work?

    What if I have a command button whose hyperlink value is changed when the value of my field [Location] is changed or updated. This way I am using hyperlinks instead of OLE links. Would this be a cleaner way of doing it?
    You know, I'm sick of following my dreams, man. I'm just going to ask where they're going and hook up with 'em later

  7. #7
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    'plonk' an image control onto your form

    mycontrolname.Picture = mypathtoimage

    you can be a little bit more creative by loading another image first, one you knwo that already exists

    On Error Resume Next
    Image1.Picture = pathtomydefaultimage
    On Error Resume Next
    Image1.Picture = pathtomyimage


    ive used this technique to display an 'image not found' image and then attempt to load the image from the db. if the image cannot be loaded from the db then the "image not found" image is retained

    you could expand the error function by checking if the image exists

    AS I see it you can have 2 faults, either there is no image reference in the db
    OR the image reference is wrong (either a typo, the image has been moved/delete)
    I'd rather be riding on the Tiger 800 or the Norton

  8. #8
    Join Date
    Feb 2004
    Posts
    214

    I appreciate your help on this

    I've decided to use the post below to get the file path into a text box.
    http://www.dbforums.com/showthread.php?t=1635007

    Then I set the value of the hyperlink on a command button to the value in my location text box.
    You know, I'm sick of following my dreams, man. I'm just going to ask where they're going and hook up with 'em later

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •