NorwalkPhil
Programmer
I am creating a PDF from an Access report with this code:
vRptNm = lstSelectedRpt.value
vRptFile = "c:\" & vRptNm & ".PDF"
DoCmd.OpenReport vRptNm ,acViewPreview
DoCmd.OutputTo acOutputReport,"",acFormatPDF, vRptFile, false
This works fine. Now I want to store the report in an OLE Object field in a table (so it can be uploaded into an Oracle BLOB field).
I created a bound object frame (OLERpt) on my form and assign the respective values to it via:
With Me.OLERpt
.OLETypeAllowed = acOLEEmbedded
.SourceDoc = vRptFile
.Action = acOLECreateEmbed
End With
then move it to the table field via:
Set rs = db.OpenRecordset("MyTable")
rs.AddNew
rs!RptDesc = vRptNm
OLECtr = 1
Do Until (Not IsNull(rs!Report )) Or OLECtr > 5
rs!Report = Me.OLERpt
OLECtr = OLECtr + 1
Loop
rs!WhenCreated = now()
rs.Update
This works sometimes (you can see by the counter that I may have to attempt it 5 times. This usually gets a report in there), but... Here's my real problem
This routine is called in succession for however many reports the user has selected. Usually, the report that is saved in the table is not necessarily the present report being processed but the previous one or two previous.
I concluded that it takes Access too long to create the embedded object in the form and the following code is already executing before it does. If I run the routine one report at a time and step it through with the debugger, everything works fine.
Is there a way to 'wait' for the embedded object to complete until continuing?
- OR -
Can I create a dynamic OLE Object in VBA and not use the bound object frame on the form at all?
I am using DAO.
Sorry about the long winded explanation and I sincerely appreciate your attention!
vRptNm = lstSelectedRpt.value
vRptFile = "c:\" & vRptNm & ".PDF"
DoCmd.OpenReport vRptNm ,acViewPreview
DoCmd.OutputTo acOutputReport,"",acFormatPDF, vRptFile, false
This works fine. Now I want to store the report in an OLE Object field in a table (so it can be uploaded into an Oracle BLOB field).
I created a bound object frame (OLERpt) on my form and assign the respective values to it via:
With Me.OLERpt
.OLETypeAllowed = acOLEEmbedded
.SourceDoc = vRptFile
.Action = acOLECreateEmbed
End With
then move it to the table field via:
Set rs = db.OpenRecordset("MyTable")
rs.AddNew
rs!RptDesc = vRptNm
OLECtr = 1
Do Until (Not IsNull(rs!Report )) Or OLECtr > 5
rs!Report = Me.OLERpt
OLECtr = OLECtr + 1
Loop
rs!WhenCreated = now()
rs.Update
This works sometimes (you can see by the counter that I may have to attempt it 5 times. This usually gets a report in there), but... Here's my real problem
This routine is called in succession for however many reports the user has selected. Usually, the report that is saved in the table is not necessarily the present report being processed but the previous one or two previous.
I concluded that it takes Access too long to create the embedded object in the form and the following code is already executing before it does. If I run the routine one report at a time and step it through with the debugger, everything works fine.
Is there a way to 'wait' for the embedded object to complete until continuing?
- OR -
Can I create a dynamic OLE Object in VBA and not use the bound object frame on the form at all?
I am using DAO.
Sorry about the long winded explanation and I sincerely appreciate your attention!