Results 1 to 7 of 7
  1. #1
    kwblue
    Guest

    Preview a report through automation (Access 2000)

    Hello all,

    i would like to open a report that I created in MS Access. I can print the report with the following code but I can not preview.
    ++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++===
    Dim msaccess As Access.Application

    Set msaccess = New Access.Application
    msaccess.OpenCurrentDatabase ("c:testtest.mdb")

    msaccess.DoCmd.OpenReport "testing", acrviewPreview
    msaccess.CloseCurrentDatabase
    Set msaccess = Nothing
    ++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++

    If I use "normal" it will print out on the default printer.


    Thanks in advance,

    Andrew Mueller

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Preview a report through automation (Access 2000)

    Hi,
    Try changing acrviewPreview to acViewPreview and that should work.
    Hope that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    kwblue
    Guest

    Re: Preview a report through automation (Access 2000)

    Apologies.... That was just a type here.. I do have acViewPreview (just grabbed it from intellisense). It still does not seem to work, though. This code is running from VBA if that makes any difference.

  4. #4
    kwblue
    Guest

    Re: Preview a report through automation (Access 2000)

    Actually.... Here is what I need to do, after a little more thought process.

    I need to be able to export the document to HTML. The reason for this is that my VBA host application has disabled any form ot task-switching. But, since it is an ActiveX container, I can embed the webbrowser control from MS and then open the document for preview. How do I go about doing this? I looked for export through the automation interfaces and did not see it. Could I use msaccess.DoCmd.OutputTo to do this? If so, what is the constant for [outputformat] and how might I use this properly?

    Thanks in advance,

    Andrew Mueller

  5. #5
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Preview a report through automation (Access 2000)

    Sorry - I've just noticed a couple of things:
    1. You're closing your database immediately after opening the report - this will also close your report!
    2. You may need to add a line like:
    msaccess.visible = true
    or you won't actually be able to see the database and/or report anyway.
    I'd suggest commenting out your closecurrentdatabase line just to make sure the report is actually previewing. You may need to allow the user to close the database, or add some code to the report's close event.
    Hope that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

  6. #6
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Preview a report through automation (Access 2000)

    Hi,
    Try something like:
    msaccess.DoCmd.OutputTo acOutputReport, "reportnamehere", acFormatHTML, "outputfilenamehere", True
    Note: The True argument at the end should automatically launch a Web Browser with the output file loaded.
    Hope that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

  7. #7
    kwblue
    Guest

    Re: Preview a report through automation (Access 2000)

    Thank you!!!! That was perfect. I changed the True arguement to False and then loaded the picture into the webbrowser control from Microsoft.

    Basically:

    Webbrowser1.navigate "C:report.htm"

    Thanks again,

    Andrew Mueller

Posting Permissions

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