Solved

Programmatically adding OLE link?

Posted on 2002-04-30
3
355 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
Comment Utility
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

Expert Comment

by:Jim Dettman (Microsoft MVP/ EE MVE)
Comment Utility
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
Comment Utility
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
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…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

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

17 Experts available now in Live!

Get 1:1 Help Now