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

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 947
  • Last Modified:

acOLECreateLink

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
piggles
Asked:
piggles
  • 4
  • 3
1 Solution
 
TrygveCommented:
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
 
pigglesAuthor Commented:
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
 
TrygveCommented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
pigglesAuthor Commented:
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
 
TrygveCommented:
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
 
pigglesAuthor Commented:
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
 
TrygveCommented:
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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now