Solved

acOLECreateLink

Posted on 1998-09-24
7
932 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
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…
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…

636 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