Solved

Programmatically adding OLE link?

Posted on 2002-04-30
3
357 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

896 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

13 Experts available now in Live!

Get 1:1 Help Now