Solved

acOLECreateLink

Posted on 1998-09-24
7
911 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
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…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

808 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