Solved

acOLECreateLink

Posted on 1998-09-24
7
886 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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Familiarize people with the process of utilizing SQL Server functions 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 Ac…
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…

757 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

19 Experts available now in Live!

Get 1:1 Help Now