Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Programmatically adding OLE link?

Posted on 2002-04-30
3
Medium Priority
?
370 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 150 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 58
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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

972 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