Easy printing of documents with photos with access

Source: Internet
Author: User
Tags exit empty insert integer access database
access| Print recently I received a task, to the student's certificate information and photos printed to the 3+1 Skills certificate template, and also to be uploaded to the Internet for employers to inquire. The original data is divided into two parts, including the student's name, ID number, certification project, certificate number and other information of the Excel table, the other part is classified by the certification project, the name of the student name of the photo, the picture size is 90x120 pixels, the picture format is JPG. (Click to see more software usage tips)

Taking into account the urgency of the time, there are user-operated ease of use, the Internet to query the compatibility of the required database, so decided to choose access to develop. Access has powerful form creation, Report printing, and VBA programming capabilities that are sufficient for the development of most small database application systems.

Creating databases and Tables

1. Open Microsoft Office Access, create an empty database, and put it under the same folder as the photo catalog.

2. Use the "file → get External data → import" feature to import an Excel table directly into Access and save it as a "certificate Information" table.

Create a Certificate Information report

1. Create a "certificate Information" report, insert an image control, set its Picture property to a certificate template picture, set its size to the size of the certificate template, and set its visibility to no, which facilitates typesetting of the certificate information and does not print; Then insert the list of fields to print, and set the font and size , and then insert an image control, place it where you print the photo, set its size to the size of the photo, and set its name to "Stuimg."

2. Click the menu bar "view → code" order, enter the VBA code writing window, write the following code:

Private Sub principal _format (Cancel As Integer, FormatCount as Integer)

Dim Imgpath as String

' Get photo path based on application path, certified project name, name

Imgpath = Application.CurrentProject.Path + "\" + Certified project. Text + "\" + name. text+ ". jpg"

' Determine if a photo exists, or if it doesn't exist, display a blank picture.

If Dir (Imgpath) = "" Then Imgpath = Application.CurrentProject.Path + "\noimg.bmp"

Stuimg.picture = Imgpath

End Sub

Create a print preview panel form

1. Create the print preview panel, place a text box for the query in turn, and name it "InputName"; two command buttons "preview", "Close".

2. Click the menu bar "view → code" order, enter the VBA code writing window, write the following code:

Public Stuname as String ' defines global variables Stuname

Sub Printreports (PrintMode as Integer)

' Create print Preview subroutine

Dim Strwherecategory as String

If stuname <> Empty Then

Strwherecategory = "name = '" + stuname + "" "

End If

DoCmd.OpenReport "certificate Information", PrintMode, Strwherecategory

DoCmd.Close acform, "Print preview panel"

End Sub

Private Sub Inputname_change ()

' Assignments the text box input to the global variable sname to qualify print preview

Stuname = InputName. Text

End Sub

Private Sub Preview _click ()
' Preview the report, this procedure uses a custom Printreports subroutine

Printreports Acpreview

End Sub

Private Sub Close _click ()

' Close form

DoCmd.Close

End Sub

Create a Main Switchboard form

1. Create "Main Switchboard", place three command buttons "print student certificate", "Return Data Window", "Exit Management System".

2. Click the menu bar "view → code" order, enter the VBA code writing window, write the following code:

Private Sub Print Student Certificate _click ()

Dim Strformname as String

Strformname= "Print Preview Panel"

' Open the Print preview panel

DoCmd.OpenForm Strformname,,,,, Acdialog

End Sub

Private Sub closes the current window _click ()

Dim strDocName as String

strDocName = "Certificate Information"

' Close the main Switchboard ' form.

DoCmd.Close

' Set focus to the Database window, and select the ' Certificate Information ' table.

Docmd.selectobject actable, strDocName, True

End Sub

Private Sub Exit Management System _click ()

' Exit Microsoft Access.

Docmd.quit

End Sub

To display the primary switchboard when starting up

Click the menu bar "tools → start" command, open the Startup Settings window, select the main switchboard under the "Show form → page" option, and cancel "Show Database window" so that the main Switchboard form is automatically displayed the next time you open the Access database. The reader can also decide whether to cancel the menu bar and shortcut menu bar, and if you want to display them after canceling, you can hold down the SHIFT key when you open the Access database.

At this point, the skill certificate printing system has been developed. The system is debugged by Windows Server SP4, Microsoft Office Access 2003, and interested readers can download to the author's website (http://www.cqie.net/opus/).



Related Article

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.