- 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?
a virtual beer for anyone who knows...
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 :cheers: :cheers:](/styles/default/custom/smilies/cheers.gif)