在VB中运行Microsoft Access报表的好方法
原作者:www.upwinder.com 添加时间:2007-09-01 原文发表:2007-08-31 人气:6 来源:未知
| 在VB中如何使用直观、简便的报表一直是很多人关心的问题, Crystal Reports用起来又不太理想。现介绍一在VB中运行Microsoft ACCESS报表的方法,用起来还不错。 逆风编程精品
利用Automation运行Microsoft ACCESS报表
1. 使用Microsoft ACCESS建立数据库(如:novelty.mdb)的相关报表(如:rptEmployess)。
2. 创建引用
在VB中使用“Project References"菜单创建一个对Microsoft ACCESS 8.0 Object Library的引用。
3. 程序清单
'References MS ACCESS 8.0 Object Library (this
'code will work with any verson of ACCESS that
'supports Automation)
Dim MSAccess As ACCESS.Application
Private sub Command1_Click()
Set MSAccess=NEW ACCESS.Application
MSACCESS.OpenCurrentDatabase(App.Path & "\novelty.mdb")
MSACCESS.DoCmd.OpenReport "rptEmployess",acViewNormal
MSACCESS.CloseCurrentDatabase
Set MSACCESS=Nothing
end Sub
注:acViewNormal告知ACCESS打开该报表并立即打印。
这种方法有个缺点,就是运行环境中必须装有MS ACCESS。 |
 本文章所属分类: 首页
→ VB
|
文章搜索
热门文章
推荐文章
最新文章
|