dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Printing Reports Created in Access2000 from vb?

  1. #1
    Join Date
    Mar 2002
    Posts
    138

    Printing Reports Created in Access2000 from vb?

    Is this possible?

  2. #2
    Join Date
    Apr 2002
    Location
    Melbourne, Victoria, Australia
    Posts
    1,792
    Sort of....

    Create an empty table in MS Access, containing the fields you want to report on.

    Create the report from this table.

    Create another table called for your opening parameters (ie reportname & reporttype)

    Create an autoexec module in Access that searches the parameters table for the reportname & reporttype.

    Create another module (OpenReport) that opens the report, taking in the reportname and reporttype

    Create another module for cleaning up (ie deleting the records from the tables) on exit

    create a recordset in VB containing the records.

    Pass the recordset into the (access) table concerned

    open access via vb - the autoexec will be called, thereby opening the report.

    Close access in your exit module after the report is closed.

    The only problem is, you might need the MS Access redistributables if the user doesn't have Access on their machine and you are distributing an mde file.

    Its not the same as what you can do with crystal, but its close....

  3. #3
    Join Date
    Mar 2002
    Posts
    138

    need help with crystal

    I much rather use crystal. I have 7.0, but I've never really used it before. Do you know of any really good help sites or anything like that about crystal reports??? Or somewhere where I can get my hands on some copies of reports that I can check out the design of?

  4. #4
    Join Date
    Apr 2002
    Location
    Melbourne, Victoria, Australia
    Posts
    1,792
    I learnt to use crystal from the help files. Unfortunately my current place of work doesn't use crystal, so I don't have any copies of reports I could put here.

  5. #5
    Join Date
    Sep 2001
    Location
    IL, USA
    Posts
    1,090

    Re: Printing Reports Created in Access2000 from vb?

    Originally posted by jshipley
    Is this possible?
    Yes.
    Code:
    'Add reference to Microsoft Access 9.0 Object Library
    Private Sub Command1_Click()
       Dim acc As Access.Application, dbName As String, ReportName As String
       'dbName is the database with the report to print
       dbName = "c:\new.mdb"
       'ReportName is the name of the report created in the database
       ReportName = "ACCTYPE"
       Set acc = New Access.Application
       acc.OpenCurrentDatabase dbName
       acc.DoCmd.OpenReport ReportName, acViewNormal
       acc.CloseCurrentDatabase
       acc.Quit
       Set acc = Nothing
    End Sub

  6. #6
    Join Date
    Apr 2002
    Location
    Melbourne, Victoria, Australia
    Posts
    1,792
    MKSa - that will only work if your data is contained in that database. What about if your data is contained in a SQL database - then you will have to pass a recordset in to the access db otherwise there will be no data to report on.

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)