unbound OLE PDF Object in Access Report doesn't update

Joined
May 31, 2011
Messages
2
Reaction score
0
Hi guys.
I'm having a big problem with displaying a linked ole object in a report. I'm trying use a dynamically created unbound sourcename. It's a pdf - which can change based on the batch number, and stored in a static folder. I store the filename in a field of a query, which is the source of the form and the report.

Then I added the form as a subreport in my access report. It displays great the first time. But if I run the report again, it doesn't update the ole object. I'm pulling my hair out trying to figure out why. I open the form and BAM it looks good. But the report stays the same.

In case any of you can help me please let me know, I would really appreciate it!

Here is my form, frmLinkFix...the record source is a query that has the pathname in a field (Imagepath). I have the picture type as Linked, in Size Mode Zoom.
Private Sub Form_Current()
CallDisplayImage
End Sub

Private Sub CallDisplayImage()
On Error GoTo Form_Error
Dim bPath As String
bPath = "BlankTechRpt.pdf"
Dim sPath As String
sPath = Me![Imagepath]
With Me![OLE1]
.Locked = False
.Enabled = True
'OLE1.Class = "Paint.Picture" ' Set class name.
.Class = "AcroExch.Document.8"
' Specify type of object.
.OLETypeAllowed = acOLELink
' Specify source file.
.SourceDoc = sPath
' Specify data to create link to.
.SourceItem = ""
' Create linked object.
.Action = acOLECreateLink
' Adjust control size.
.SizeMode = acOLESizeZoom
End With

Form_Exit:
Exit Sub

Form_Error:
MsgBox "Error: " & Error & " (" & Err & ")"
Me![OLE1].Action = acOLEDelete
Me![OLE1].SourceDoc = ""
Me![OLE1].Action = acOLECreateLink
Me![OLE1].SizeMode = acOLESizeZoom
' Resume Next

End Sub
Ok this works great in the form, but then I view this mofo in my report it doesn't update, unless I totally close access and reopen it. Sometimes that works.

On my report, under the property sheet, the subform's name is frmLinkFix (my form) and the source object is Form.frmLinkFix. On the detail properties, It's an Unbound Object Frame, OLE type is linked, and the Source Doc is populated with the path to the pdf file name. That all looks good, but what actually displays in the report preview is the old file name, not the new one.

Is there something I missed to make the value displayed actually match the source of the OLE object?

I did find this article:
Unbound OLE Object Frame on Report Is Not Updated
http://support.microsoft.com/kb/202174

But it doesn't apply to this example, because the microsoft "fix" assumes that the source document will always stay named the same. My problem is that the source file name is dynamic, and the report has to find the appropriate pdf and display it on report when it's generated.

The form is updating. But the subform on the report does not. Can anybody help? Maybe I was thinking about this the wrong way - is there a better way?
:cheers: a virtual beer for anyone who knows...
 
Joined
May 31, 2011
Messages
2
Reaction score
0
Hi guys. In case anyone finds this, I had to change how I was thinking about attaching pdf's in my access report. Instead of trying to programatically change the OLE.Source Doc object of the form to the new pdf, I used a static pdf name as the ole object in my form (i.e. Temp.pdf) and used the following example to change my form.
http://support.microsoft.com/kb/183277

It had no recordsource and I made sure to set the Enabled and Locked properties correctly. Then in my report, on Open event, I just copied/renamed the pdf I wanted to attach using good old fso - and renamed it to the Temp.pdf filename of my form. It works like a charm and is a lot easier than the alternatives I was working on. :dance:
 

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