Solved

Programmatically adding OLE link?

Posted on 2002-04-30
3
359 Views
Last Modified: 2008-02-26
Using Access 2000, I can manually link a photo to my OLE Object field in my database by right-clicking the target field, choosing Insert Object, Create from file, check the Link checkbox and navigate to the graphic I want. Assuming I have the full path to the graphic in a variable, how can I programmatically accomplish this, and is it possible to prevent to automatic update functionality at the same time? Thanks for assistance in advance.
0
Comment
Question by:Chrix
3 Comments
 
LVL 4

Accepted Solution

by:
zuijdhoek earned 50 total points
ID: 6983174
Chrix,

1. Create a form, drag an imagecontrol (called imgTest), a Common Dialog ActiveX component (called objDlg) and a commandbutton (called cmdGetPic) into it.
2. Create a reference to the Scripting Runtime library
3. Bind this form to your table which contains the full pathname of the graph you want to display and implement code below (I grabbed all code of my form-module):  
4. Replace field ImgagePath with the fieldname of the field of your table which contains the full pathname of the graph to display.

Hope this helps you out,

Mark

Option Compare Database
Option Explicit

Private mObjDlg As CommonDialog

Private Sub cmdGetPic_Click()
On Error GoTo ExitHere
  Dim fso As FileSystemObject
 
  Set fso = New FileSystemObject
 
  With mObjDlg
    .InitDir = fso.GetParentFolderName(Nz(Me.ImagePath))
    .ShowOpen
   
    txtPath = .FileName
    Call Form_Current
   
  End With
 
ExitHere:

  Set fso = Nothing
  Exit Sub
 
End Sub

Private Sub Form_Close()
  Set mObjDlg = Nothing
End Sub

Private Sub Form_Current()
  imgTest.Picture = Nz(Me.ImagePath)
End Sub

Private Sub Form_Load()
  Set mObjDlg = Me.objDlg.Object
End Sub

Private Sub imgTest_DblClick(Cancel As Integer)
  Call Form_Current
End Sub
0
 
LVL 57
ID: 6983202
Take a look at the following MSKB article:

ACC: Programmatically Link or Embed an Object in a Form (95/97)

http://support.microsoft.com/default.aspx?scid=kb;en-us;Q158929

  It applies to Access 2000 as well.  Also, there are several other articles in the MSKB on handling linked/embedded objects, many with code samples.  You might want to jump over to Microsoft's site and do a search on Access for "embedded".

Jim.
0
 

Author Comment

by:Chrix
ID: 7063873
Sorry for the delay.

Both are helpful so I've decided to give 50 points each. JDettman there's a new question for you - pls answer and I'll accept it.

Thanks.
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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

828 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