Solved

acOLECreateLink

Posted on 1998-09-24
7
901 Views
Last Modified: 2012-06-21
In my database (Access 8) I have a table for holding links to documents which relate to the Personnel file for each Applicant.  When a new link is to be added my code looks to see if the object to be linked  is already in the table, and iff not is supposed to add it.  The following is a snippet of my code for creating the link.

If Found = False Then
    DoCmd.GoToRecord , , A_NEWREC
    Forms![Applicant Picture File]![UniqueVal] = [UVal]
    DoCmd.Requery
    DoCmd.GoToRecord , , A_LAST
   Forms![Applicant Picture File]![Applicant Picture File SubForm].Form![Path] = Pth & Match
   Forms![Applicant Picture File]![Applicant Picture File SubForm].Form![Picture].OLETypeAllowed = acOLELinked
   Forms![Applicant Picture File]![Applicant Picture File SubForm].Form![Picture].SourceDoc = Pth & Match
   Forms![Applicant Picture File]![Applicant Picture File SubForm].Form![Picture].Action = acOLECreateLink
End If

The last line brings up the error "Microsoft Access tried to create an OLE link, but there was no source document for this object", but when I look at the preceding line (which sets the SourceDoc) in the debugger it reveals the name of the file I wish to link.

Anyone got any clues as to how to fix the problem??
0
Comment
Question by:piggles
  • 4
  • 3
7 Comments
 
LVL 12

Expert Comment

by:Trygve
ID: 1963516
What type of document are you trying to link to. I think you will have to set the Ole.Class property. Try inserting the object into the control manually and see what class you end up with. Then have you code set the same class.
0
 

Author Comment

by:piggles
ID: 1963517
Thanks for the reply trygve.  There are several different document types including .DOC files, .TIF files, .XLS files etc.  Is there a way to "auto" set the Class Name?
0
 
LVL 12

Expert Comment

by:Trygve
ID: 1963518
Not quite sure. Perhaps you could implement a SELECT CASE test for your document ID.

Something like this;

Dim MyClass as String

SELECT CASE Match ' Your Document variable
  CASE DOC
    MyClass = "Word.Document.8"
  CASE TIF
    MyClass = "Paint.Picture"
' etc.
' You will have to figure out the correct Class ID for each type at your computer. It depends on the programs installed.
END SELECT
Forms![Applicant Picture File]![Applicant Picture File SubForm].Form![Picture].Class = MyClass
0
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 

Author Comment

by:piggles
ID: 1963519
Thanks again Trygve

I have now done what you suggest, but I still get the same error message.  

Also, I note that when I use the wizard to try to link a TIFF file it will only embed it, and will not just create a link.

0
 
LVL 12

Expert Comment

by:Trygve
ID: 1963520
I have done some testing and was able to reproduce your error to some degree. You can forget my comment on setting the class property. This was not necessary in my test app. The only time the error occured was when I left out the line setting the SourceDoc. Once I set this property to anything at all I got other errors.

You say that you code shows a value for the property in debug mode. I can only guess at this point, but it would be interesting to know what happens if you save the record before trying to perform the link. Try inserting a docmd.runcommand accmdSaveRecord line just before the link line. If this does not help and you still have hopes for me you could email me the objects involved and I will have a look at it for you (EMail: Trygve@Omega.No). I will keep looking in the Microsoft Developer CDs etc. but I will not be able to reproduce your application 100% at the information available.
0
 

Author Comment

by:piggles
ID: 1963521
Hi Trygve - Thanks again!!

I have tried saving the record, but still get the same error.  I think I will use hyperlinks instead which should give the result I need.  

You have been very helpful.  If you would like to change your comments into an answer I will happily give you the points.
0
 
LVL 12

Accepted Solution

by:
Trygve earned 100 total points
ID: 1963522
Thanks, always glad to be of help !

The offer to have a look at it still stands.

Have a nice day !
Trygve
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

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…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
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…
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…

778 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