实例编程:用Access打印带相片的证件
最近笔者接到一个任务,要将学生的证书信息及相片 打印 到3+1技能证书模板上,并且还要传到网上供用人单位查询。原始数据分两部分,一部分是包含学生姓名、身份证号、认证项目、证书编号等信息的Excel表;另一部分是按认证项目分类、以学生姓名为名的相片,
考虑到时间上的紧迫性,还有用户操作的易用性,以后上网查询所需数据库的兼容性,因此决定选用Access来开发。Access具有强大的窗体创建、报表打印、VBA编程功能,足以胜任大部分小型数据库应用系统的开发。
创建数据库和表
1. 打开Microsoft Office Access,创建一个空数据库,与相片的分类目录放在同一个文件夹下。
2. 使用“文件→获取外部数据→导入”功能将Excel表直接导入Access中,保存为“证书信息”表。
创建证书信息报表
1. 创建“证书信息”报表,先插入一个“图像”控件,设置其图片属性为证书模板图片,设置其大小为证书模板的大小,设置其可见性为否,这样有利于证书信息的排版,且不会打印出来;再依次插入要打印的字段列表,设置好字体和字号;最后再插入一个“图像”控件,放置于打印相片的地方,设置其大小为相片的大小,设置其名称为“stuimg”。
2. 依次点击菜单栏“视图→代码”命令,进入VBA代码编写窗口,编写如下代码:
Private Sub 主体_Format(Cancel As Integer, FormatCount As Integer)
Dim imgpath As String
' 依据应用程序路径、认证项目名称、姓名得到相片路径
imgpath = Application.CurrentProject.Path +"" +认证项目.text +""+ 姓名.Text+".jpg"
' 判断照片是否存在,如果不存在则显示一张空白的图片。
If Dir(imgpath) = "" Then imgpath = Application.CurrentProject.Path + "noimg.bmp"
Stuimg.Picture = imgpath
End Sub
创建打印预览面板窗体
1. 创建“打印预览面板”,依次放置一个用于查询的文本框,并命名为“inputname”;两个命令按钮“预览”、“关闭”。
2. 依次点击菜单栏“视图→代码”命令,进入VBA代码编写窗口,编写如下代码:
Public stuname As String '定义全局变量stuname
Sub PrintReports(PrintMode As Integer)
' 创建打印预览子程序
Dim strWhereCategory As String
If stuname Empty Then
strWhereCategory = "姓名= '" + stuname + "'"
End If
DoCmd.OpenReport "证书信息", PrintMode, , strWhereCategory
DoCmd.Close acForm, "打印预览面板"
End Sub
Private Sub inputname_Change()
' 将文本框输入的字符赋给全局变量sname,用于给打印预览限定条件
stuname = inputname.Text
End Sub
Private Sub 预览_Click()
' 预览报表,本过程使用自定义的 PrintReports 子程序
PrintReports acPreview
End Sub
Private Sub 关闭_Click()
' 关闭窗体
DoCmd.Close
End Sub
创建主切换面板窗体
1. 创建“主切换面板”,放置三个命令按钮“打印学生证书”、“返回数据窗口”、“退出管理系统”。
2. 依次点击菜单栏“视图→代码”命令,进入VBA代码编写窗口,编写如下代码:
Private Sub 打印学生证书_Click()
Dim strFormName As String
strFormName="打印预览面板"
' 打开打印预览面板
DoCmd.OpenForm strFormName, , , , , acDialog
End Sub
Private Sub 关闭当前窗口_Click()
Dim strDocName As String
strDocName = "证书信息"
' 关闭“主切换面板”窗体。
DoCmd.Close
' 设置焦点到数据库窗口;选择“证书信息”表。
DoCmd.SelectObject acTable, strDocName, True
End Sub
Private Sub 退出管理系统_Click()
' 退出 Microsoft Access.
DoCmd.Quit
End Sub
设置启动时显示主切换面板
依次点击菜单栏“工具→启动”命令,打开“启动”设置窗口,在“显示窗体→页”选项下选择主切换面板,并取消“显示数据库窗口”,这样在下一次打开此Access数据库时,就会自动显示主切换面板窗体。读者也可根据自己的需要决定是否取消菜单栏和快捷菜单栏,如果取消以后又要显示它们,可以在打开Access数据库时按住Shift键。
至此,技能证书打印系统开发完毕。本系统在Windows 2000 Server SP4、Microsoft Office Access 2003下调试通过

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

SQL IF statements are used to conditionally execute SQL statements, with the syntax as: IF (condition) THEN {statement} ELSE {statement} END IF;. The condition can be any valid SQL expression, and if the condition is true, execute the THEN clause; if the condition is false, execute the ELSE clause. IF statements can be nested, allowing for more complex conditional checks.

How to configure Zend in Apache? The steps to configure Zend Framework in an Apache Web Server are as follows: Install Zend Framework and extract it into the Web Server directory. Create a .htaccess file. Create the Zend application directory and add the index.php file. Configure the Zend application (application.ini). Restart the Apache Web server.

Methods to solve the cross-domain problem of Vue Axios include: Configuring the CORS header on the server side using the Axios proxy using JSONP using WebSocket using the CORS plug-in

The advantage of multithreading is that it can improve performance and resource utilization, especially for processing large amounts of data or performing time-consuming operations. It allows multiple tasks to be performed simultaneously, improving efficiency. However, too many threads can lead to performance degradation, so you need to carefully select the number of threads based on the number of CPU cores and task characteristics. In addition, multi-threaded programming involves challenges such as deadlock and race conditions, which need to be solved using synchronization mechanisms, and requires solid knowledge of concurrent programming, weighing the pros and cons and using them with caution.

The main reasons why you cannot log in to MySQL as root are permission problems, configuration file errors, password inconsistent, socket file problems, or firewall interception. The solution includes: check whether the bind-address parameter in the configuration file is configured correctly. Check whether the root user permissions have been modified or deleted and reset. Verify that the password is accurate, including case and special characters. Check socket file permission settings and paths. Check that the firewall blocks connections to the MySQL server.

The key to PHPMyAdmin security defense strategy is: 1. Use the latest version of PHPMyAdmin and regularly update PHP and MySQL; 2. Strictly control access rights, use .htaccess or web server access control; 3. Enable strong password and two-factor authentication; 4. Back up the database regularly; 5. Carefully check the configuration files to avoid exposing sensitive information; 6. Use Web Application Firewall (WAF); 7. Carry out security audits. These measures can effectively reduce the security risks caused by PHPMyAdmin due to improper configuration, over-old version or environmental security risks, and ensure the security of the database.

This article describes how to effectively monitor the SSL performance of Nginx servers on Debian systems. We will use NginxExporter to export Nginx status data to Prometheus and then visually display it through Grafana. Step 1: Configuring Nginx First, we need to enable the stub_status module in the Nginx configuration file to obtain the status information of Nginx. Add the following snippet in your Nginx configuration file (usually located in /etc/nginx/nginx.conf or its include file): location/nginx_status{stub_status

Apache server is a powerful web server software that acts as a bridge between browsers and website servers. 1. It handles HTTP requests and returns web page content based on requests; 2. Modular design allows extended functions, such as support for SSL encryption and dynamic web pages; 3. Configuration files (such as virtual host configurations) need to be carefully set to avoid security vulnerabilities, and optimize performance parameters, such as thread count and timeout time, in order to build high-performance and secure web applications.
