Results 1 to 2 of 2

Thread: How to print a report from a database?

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Posts
    13

    Question

    I'm a novice.
    I wonder how to print a report by VB?
    The DataReport seems to need changeless DataSource,but i want to change the datasource at runtime.
    How to manage it?
    Anyone be kind enough to tell me?
    Thanks beforehand.

  2. #2
    Lively Member
    Join Date
    Jul 2000
    Posts
    72
    This should help


    Dim appAccess As Access.Application
    Dim strDB As String

    Const strConPathToSamples = "D:\Program " _
    & "Files\Microsoft _
    Office\Office\Samples\Contact.mdb"
    " this is the path to the DB

    strDB = strConPathToSamples & "Contact.mdb"

    ' Create new instance of Microsoft Access.
    Set appAccess = CreateObject("Access.Application")
    ' Open database in Microsoft Access window.
    appAccess.OpenCurrentDatabase strConPathToSamples

    'appAccess.DoCmd.OpenForm "Orders" ' will open the form
    appAccess.DoCmd.OpenReport "ActionItems",
    acViewPreview ' will open the report, if in preview will show
    ' if in acviewNormal will print

    appAccess.Visible = True ' just shows access

    then to change to a new DB or report, just close the object

    set appAccess = Nothing
    then rerun above with new Parameters




    [Edited by jtm7699 on 07-05-2000 at 04:13 PM]
    VB 6 Professional Edition

Posting Permissions

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



Click Here to Expand Forum to Full Width