VB + Access Report

Source: Internet
Author: User

In VB, how to use intuitive and simple reports has always been a concern of many people. Crystal Reports is not ideal for use. This article describes how to run Microsoft Access Report in VB.

Method 2:

 

Use automation to run Microsoft Access reports

 

1. Use Microsoft Access to create relevant reports (such as rptemployess) for databases (such as novelty. mdb ).

 

2. Create a reference

 

Use the "Project references" menu in VB to create an object library for Microsoft Access 8.0

 

.

 

3.ProgramList

 

Note: References MS Access 8.0 Object Library (this

 

Note: Code will work with any Verson of access that

 

Note: supports automation)

 

Dim msaccess as access. Application

 

Private sub commandementclick ()

 

Set msaccess = new access. Application

 

Msaccess. opencurrentdatabase (App. Path & "ovelty. mdb ")

 

 

 

Msaccess. docmd. openreport "rptemployess", acviewnormal

 

Msaccess. closecurspondatabase

 

Set msaccess = nothing

 

End sub

 

Note: acviewnormal informs access to open the report and print it immediately.

 

This method has the disadvantage that MS Access must be installed in the runtime environment.

 

Method 2:

Dim objacc as object

Set objacc = Createobject ("access. application ")

Objacc. opencurrentdatabase "C:/DB. mdb"

Objacc. docmd. openreport "table 1"

Objacc. Quit

Set objacc = nothing

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.