Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2009

    Unanswered: Prmblem Saving PDF to OLE Object Field in Table

    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!RptDesc = vRptNm
    OLECtr = 1
    Do Until (Not IsNull(rs!Report )) Or OLECtr > 5
    rs!Report = Me.OLERpt
    OLECtr = OLECtr + 1
    rs!WhenCreated = now()

    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!
    Last edited by PRicci; 08-31-09 at 17:54.

  2. #2
    Join Date
    Mar 2009


    I forgot to add that I'm using DAO

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts