Solved

Programmatically adding OLE link?

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
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…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

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