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