acOLECreateLink and Datasheet View

F

Fly Girl

Can anyone shed any light on why the following code works
fine in Form view but gives error #2778 "No Source
Document" when run from Datasheet view?

Code:

With frm![EventsSub].Form.oleLinked
.Enabled = True
.Locked = False
.OLETypeAllowed = acOLELinked
.SourceDoc = strLinkFilePath
.Action = acOLECreateLink
End With

Thanks for your help!
 
A

Alick [MSFT]

Hi,

Could you please post the reproduce steps? I did a simple test and didn't
get the error. What I did is open the form in form view and then click
View->DataSheet View; when in datasheet view, there is no column for OLE
bound control object.

Please feel free to reply to the threads if you have any concerns or
questions.



Sincerely,

Alick Ye, MCSD
Product Support Services
Microsoft Corporation
Get Secure! - <www.microsoft.com/security>

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: "Fly Girl" <[email protected]>
|
| Can anyone shed any light on why the following code works
| fine in Form view but gives error #2778 "No Source
| Document" when run from Datasheet view?
|
| Code:
|
| With frm![EventsSub].Form.oleLinked
| .Enabled = True
| .Locked = False
| .OLETypeAllowed = acOLELinked
| .SourceDoc = strLinkFilePath
| .Action = acOLECreateLink
| End With
|
| Thanks for your help!
|
 
A

Amy Vargo

Hi,

My name is Amy Vargo. Thank you for using the Microsoft Access Newsgroups.

I have read the description of your issue. I created a sample using a form
and running the following code behind the OnClick event of a command button
when the form was set to Single Form View. This works perfectly. For each
record, I am able to link to the specified Word document successfully.
However, if I place the code behind the OnCurrent even of the form, and if
the form is in Datasheet View, I can reproduce the error and the code
breaks on the .Action line of code.
When a form is in datasheet view, Access cannot determine what is the
current record or where we are applying this code to. It is as if we have
one control, but see all records for it. There is no distinction.

Is there a particular reason why you need to view the form in datasheet
view? Could you possibly display a listbox on a form with the data you
need for all other fields except for the OLE Object field, and on the form
with your bound OLE Object field, design the form so that it is
synchronized and goes to the record that the user selected from the listbox
and links to the document?

Private Sub Form_Current()
With Me![o]
.Enabled = True

.Locked = False

.OLETypeAllowed = acOLELinked

'.SourceDoc = strLinkFilePath
.SourceDoc = "C:\RudytorWhoAmI.doc"

.Action = acOLECreateLink

End With

End Sub


I hope this helps! If you have additional questions on this topic, please
respond back to this posting.


Regards,

Amy Vargo
Microsoft Access Engineer


This posting is provided 'AS IS' with no warranties, and confers no rights.
You assume all risk for your use. © 2001 Microsoft Corporation. All rights
reserved.
 
F

Fly Girl

Hi Amy,

Thanks for looking into this and I'm glad you could reproduce the
error. I figured that the problem had to do with Access not having a
clear idea of what record was current in Datasheet view.

However, since this is a rather monstrous app and the code that opens
this subform in datasheet view is built to also handle many others, I
decided to be stubborn about this. I'm actually flipping the subform
into form view and then back to datasheet view--and dealing with all
the associated agony of returning the datasheet view to exactly the
same position on the screen before letting Access repaint anything.
Code from Leban's site came in very handy.

Now I am trying to figure out two additional issues:

1. Getting XP to allow me to manually attach image files (with the
same code as given before). Here Windows Picture and Fax Viewer
crashes almost every time I try this. Ends up requiring a re-boot of
the app before the user can play with OLE attachments again. Being
able to print these files would be really nice... but no 'print' verb
or automation allowed with Windows Picture and Fax Viewer. Have had no
luck with 'PrintTo'.

2. Access has an unhandled exception when I run my 'attachment'
process via the ctl_Updated event of the OLE control. All my code runs
just fine but when it's done I get a total app crash. Alick Ye has the
scoop on this.

Thanks for your help. Hope you can put some of this to good use! There
are a few of us out here dusting out even the darkest corners of this
app.

Gail

Hi,

My name is Amy Vargo. Thank you for using the Microsoft Access Newsgroups.

I have read the description of your issue. I created a sample using a form
and running the following code behind the OnClick event of a command button
when the form was set to Single Form View. This works perfectly. For each
record, I am able to link to the specified Word document successfully.
However, if I place the code behind the OnCurrent even of the form, and if
the form is in Datasheet View, I can reproduce the error and the code
breaks on the .Action line of code.
When a form is in datasheet view, Access cannot determine what is the
current record or where we are applying this code to. It is as if we have
one control, but see all records for it. There is no distinction.

Is there a particular reason why you need to view the form in datasheet
view? Could you possibly display a listbox on a form with the data you
need for all other fields except for the OLE Object field, and on the form
with your bound OLE Object field, design the form so that it is
synchronized and goes to the record that the user selected from the listbox
and links to the document?

Private Sub Form_Current()
With Me![o]
.Enabled = True

.Locked = False

.OLETypeAllowed = acOLELinked

'.SourceDoc = strLinkFilePath
.SourceDoc = "C:\RudytorWhoAmI.doc"

.Action = acOLECreateLink

End With

End Sub


I hope this helps! If you have additional questions on this topic, please
respond back to this posting.


Regards,

Amy Vargo
Microsoft Access Engineer


This posting is provided 'AS IS' with no warranties, and confers no rights.
You assume all risk for your use. © 2001 Microsoft Corporation. All rights
reserved.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top