F
fly girl
I have an MS Access app that uses an ole container control
to allow the user to view linked files. However, when I
try to attach files to this control I am getting a strange
error: "OLE Server wasn't able to open the object".
Here's the code:
With Me!oleLinked
.Enabled = True
.Locked = False
.OLETypeAllowed = acOLELinked
.SourceDoc = strFilePath
.Action = acOLECreateLink
End With
This seemed bulletproof when I tested it in a MS Access
project file but now that I have folded it into the actual
app with an .mdb front end I get the following result:
The first time I try to run this code, it fails with the
error 2785. The second time I run it for the exact same
file, it works just fine.
Detail:
User selects file to link. Note: the control's Ole Type
Allowed property is set to "Linked" so they must choose an
existing file and it is linked to the control.
When the user moves off the control the
control_AfterUpdate code runs in which I do several things.
1) I identify the file that the user linked by parsing the
header from the database.
2) I make a copy of the user's file and place it into my
controlled directory with a record-specific name, I'll
call it 'File A'.
3) I verify that File A is there. (At this time I can go
to the directory and open the file just fine--and, of
course I close it before proceeding with the code.)
4) If File A is where I want it, I delete the link in the
control to the user's file and establish a link to File A.
Step 4 is where the code blows up. However, the exact same
file (but with a different name) was just successfully
opened by the OLE Server! GRRRR!
If I manually delete the user's file and then run the
exact same steps again, IT WORKS! The only difference
seems to be that File A exists in the controlled directory
prior to running the code in the second round and didn't
the first time.
Has anyone divined the mysteries of what is going on with
error 2785?
Thanks!
to allow the user to view linked files. However, when I
try to attach files to this control I am getting a strange
error: "OLE Server wasn't able to open the object".
Here's the code:
With Me!oleLinked
.Enabled = True
.Locked = False
.OLETypeAllowed = acOLELinked
.SourceDoc = strFilePath
.Action = acOLECreateLink
End With
This seemed bulletproof when I tested it in a MS Access
project file but now that I have folded it into the actual
app with an .mdb front end I get the following result:
The first time I try to run this code, it fails with the
error 2785. The second time I run it for the exact same
file, it works just fine.
Detail:
User selects file to link. Note: the control's Ole Type
Allowed property is set to "Linked" so they must choose an
existing file and it is linked to the control.
When the user moves off the control the
control_AfterUpdate code runs in which I do several things.
1) I identify the file that the user linked by parsing the
header from the database.
2) I make a copy of the user's file and place it into my
controlled directory with a record-specific name, I'll
call it 'File A'.
3) I verify that File A is there. (At this time I can go
to the directory and open the file just fine--and, of
course I close it before proceeding with the code.)
4) If File A is where I want it, I delete the link in the
control to the user's file and establish a link to File A.
Step 4 is where the code blows up. However, the exact same
file (but with a different name) was just successfully
opened by the OLE Server! GRRRR!
If I manually delete the user's file and then run the
exact same steps again, IT WORKS! The only difference
seems to be that File A exists in the controlled directory
prior to running the code in the second round and didn't
the first time.
Has anyone divined the mysteries of what is going on with
error 2785?
Thanks!