search
HomeDatabaseMysql Tutorial2012年计算机二级:Access如何制作复杂报表

在读这篇文章以前首先要提醒大家,Access 本身的报表也具有很强的实用性和强大的功能,只有当你发掘了其本身全部的功能却仍不能满足你对报表的特殊要求时才请使用 Excel 输出报表。很明显,使用 Excel 输出报表第一个弱点就是必须同时打开 Access 和 Excel (

在读这篇文章以前首先要提醒大家,Access 本身的报表也具有很强的实用性和强大的功能,只有当你发掘了其本身全部的功能却仍不能满足你对报表的特殊要求时才请使用 Excel 输出报表。很明显,使用 Excel 输出报表第一个弱点就是必须同时打开 Access 和 Excel (当然,你得在一台机器上同时安装 Access 和 Excel),当然如果你和我一样拥有工作在 966MHz 上的 CPU 和 256M 内存以及大容量硬盘时,那就不必考虑了,继续吧。

  首先找到 VBA 编程界面并找到"工具"菜单并单击"引用..."菜单项,在弹出的"引用"窗体中找到"现有引用"列表,在名为"Microsoft Excel x.0 Object Library"的项目前的方框内打钩。

  其次,你要做好一张空白的 Excel 电子表格,设定好显示字体、边框、打印纸张等等并将其存盘。(以下示例中该表格名为 "temp.xls" )当然啦,直接使用空白的 Excel 文件也是可以的,不过你要编程自动生成表格边框、背景颜色、单元格格式等一些内容,这些涉及到 Excel 编程,我以后会在 Excel 专栏里详细叙述,这里就不多说了。

  然后你就可以在 Access 里面制作你自己的打印预览窗体了,在窗体中安排 2 个命令按钮,考试,大提示在名为预览的按钮的 click 事件里输入以下代码:

  Private Sub ExcelPreview_Click()

  Dim xlApp As Excel.Application

  Dim xlBook As Workbook, xlSheet As Worksheet

  Set xlApp = CreateObject("Excel.Application")

  Set xlApp = New Excel.Application

  xlApp.Visible = True

  Set xlBook = xlApp.Workbooks.Open("c:reprottemp.xls")

  Set xlSheet = xlBook.Worksheets(1)

  xlSheet.Cells(3, 1) = "制表日期:" + "12" + " 月"

  '以上只更改了一个单元格内的数据,可根据需要无限次加入

  xlBook.Save

  xlSheet.PrintPreview '如果是要打印,只要把 PrintPreview 改为 PrintOut

  xlBook.close

  xlApp.Quit

  End Sub

  OK,然后就可以单击该按钮看看生成的表格如何了

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
What Are the Limitations of Using Views in MySQL?What Are the Limitations of Using Views in MySQL?May 14, 2025 am 12:10 AM

MySQLviewshavelimitations:1)Theydon'tsupportallSQLoperations,restrictingdatamanipulationthroughviewswithjoinsorsubqueries.2)Theycanimpactperformance,especiallywithcomplexqueriesorlargedatasets.3)Viewsdon'tstoredata,potentiallyleadingtooutdatedinforma

Securing Your MySQL Database: Adding Users and Granting PrivilegesSecuring Your MySQL Database: Adding Users and Granting PrivilegesMay 14, 2025 am 12:09 AM

ProperusermanagementinMySQLiscrucialforenhancingsecurityandensuringefficientdatabaseoperation.1)UseCREATEUSERtoaddusers,specifyingconnectionsourcewith@'localhost'or@'%'.2)GrantspecificprivilegeswithGRANT,usingleastprivilegeprincipletominimizerisks.3)

What Factors Influence the Number of Triggers I Can Use in MySQL?What Factors Influence the Number of Triggers I Can Use in MySQL?May 14, 2025 am 12:08 AM

MySQLdoesn'timposeahardlimitontriggers,butpracticalfactorsdeterminetheireffectiveuse:1)Serverconfigurationimpactstriggermanagement;2)Complextriggersincreasesystemload;3)Largertablesslowtriggerperformance;4)Highconcurrencycancausetriggercontention;5)M

MySQL: Is it safe to store BLOB?MySQL: Is it safe to store BLOB?May 14, 2025 am 12:07 AM

Yes,it'ssafetostoreBLOBdatainMySQL,butconsiderthesefactors:1)StorageSpace:BLOBscanconsumesignificantspace,potentiallyincreasingcostsandslowingperformance.2)Performance:LargerrowsizesduetoBLOBsmayslowdownqueries.3)BackupandRecovery:Theseprocessescanbe

MySQL: Adding a user through a PHP web interfaceMySQL: Adding a user through a PHP web interfaceMay 14, 2025 am 12:04 AM

Adding MySQL users through the PHP web interface can use MySQLi extensions. The steps are as follows: 1. Connect to the MySQL database and use the MySQLi extension. 2. Create a user, use the CREATEUSER statement, and use the PASSWORD() function to encrypt the password. 3. Prevent SQL injection and use the mysqli_real_escape_string() function to process user input. 4. Assign permissions to new users and use the GRANT statement.

MySQL: BLOB and other no-sql storage, what are the differences?MySQL: BLOB and other no-sql storage, what are the differences?May 13, 2025 am 12:14 AM

MySQL'sBLOBissuitableforstoringbinarydatawithinarelationaldatabase,whileNoSQLoptionslikeMongoDB,Redis,andCassandraofferflexible,scalablesolutionsforunstructureddata.BLOBissimplerbutcanslowdownperformancewithlargedata;NoSQLprovidesbetterscalabilityand

MySQL Add User: Syntax, Options, and Security Best PracticesMySQL Add User: Syntax, Options, and Security Best PracticesMay 13, 2025 am 12:12 AM

ToaddauserinMySQL,use:CREATEUSER'username'@'host'IDENTIFIEDBY'password';Here'showtodoitsecurely:1)Choosethehostcarefullytocontrolaccess.2)SetresourcelimitswithoptionslikeMAX_QUERIES_PER_HOUR.3)Usestrong,uniquepasswords.4)EnforceSSL/TLSconnectionswith

MySQL: How to avoid String Data Types common mistakes?MySQL: How to avoid String Data Types common mistakes?May 13, 2025 am 12:09 AM

ToavoidcommonmistakeswithstringdatatypesinMySQL,understandstringtypenuances,choosetherighttype,andmanageencodingandcollationsettingseffectively.1)UseCHARforfixed-lengthstrings,VARCHARforvariable-length,andTEXT/BLOBforlargerdata.2)Setcorrectcharacters

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool