Home

Introduction to Printing

 

Table, Query, and Form Printing

 

Introduction to Printing

Printing consists of writing or drawing, on a piece of paper, the values held by an object of a database. This means that you can print from a table, a query, or a form. Before doing this, of course the object must exist and it must have records.

To print from a table, a query, or a form, in the appropriate section of the database window, right-click the object and click Print... When you do this, the document is sent directly to the printer.

Printing Records

The tables, queries, and forms provide a fast means of printing records without having to do any particular design. Instead of directly sending a document to a printing, you can choose what records to print. To do this, you must first open the table, query, or form.

To print a particular record, if you are using a table or a query, click any cell in that record. To print a record from a table, first navigate to that record. In both cases, on the main menu, click File -> Print... This would display the Print dialog box. From it, you can click the Selected Record(s) radio button:

To print more than one record, first select them and then proceed in the same way.

Report Fundamentals

 

Introduction

While the table, the query, and the form provide a fast means of printing, their result may not be particularly appealing. The most convenient object to print from a database is a report. A report is an object in its own right. It is created and saved like one of the objects we have saved so far. Like the other Microsoft Access objects, which excludes views and stored procedures, the reports have their own section in the Database window, and it is labeled Reports.

Creating a New Report

Like a table or a form, there are various ways you create a report. From the main menu, you can click Insert -> Report. From the Reports section of the Database window, you can click the New button or, on the Database toolbar, you can click the arrow of the New Object button and click Report. Any of these actions would display the New Report dialog box:

You can create a report that would be used to print simple text that is not related to any data source. To create such a report, when in the New Report dialog box, you can click Design View, make sure the combo box is empty, and click OK. Otherwise, the New Report displays the same options as the New Form dialog box.

After creating a report, as we will see in the next few sections, to keep it in your database, you must save it by giving it a name. The name of a report follows the rules and suggestions we have applied to tables, queries, and forms so far.

Practical LearningPractical Learning: Using Different Options to Create Reports

  1. Start Microsoft Access.
    Create a blank database and name it Yugo National Bank
  2. In the Tables section of the Database window, Click the New button
  3. In the New Table dialog box, double-click Table Wizard
  4. In the first page of the wizard, click Personal
  5. In the Sample Fields list, double-click AccountTypeID, AccountType, and Description
  6. Click Next
  7. In the second page of the wizard, change the name of the table to AccountTypes and click Next
  8. Click Finish
  9. Enter a few records as follows:
     
    Account Type ID Account Type Description
    1 Checking  
    2 Saving  
    3 Certificate of Deposit  
  10. Close the table and, in the Tables section of the Database window, click AccountTypes to make sure it is selected
  11. On the Database toolbar, click the arrow of the New Object button and click AutoForm
     
  12. Close the new form
  13. When asked whether you want to save it, click Yes
  14. Accept the suggested name of the form as AccountTypes and click OK
  15. In the Database window, click AccountTypes to make sure it is selected.
    To create a new report, on the Database toolbar, click the arrow of the New Object button and click AutoReport
  16. After viewing it, close the report
  17. When asked whether you want to save the report, click Yes and click OK to accept the suggested name of the report
  18. In the Tables section of the Database window, Click the New button
  19. In the New Table dialog box, double-click Table Wizard
  20. In the first page of the wizard, click Personal
  21. In the Sample Fields list, double-click AccountTypeID, AccountType, and Notes
  22. In the Fields In My New Table list, click AccountTypeID and click Rename Field
  23. Type DepositTypeID and click OK
  24. In the Fields In My New Table list, click AccountType and click Rename Field
  25. Type DepositType and click OK
  26. In the Fields In My New Table list, click Notes and click Rename Field
  27. Type Description and click OK
  28. Click Next
  29. In the second page of the wizard, change the name of the table to DepositTypes and click Finish
  30. Switch the table to Design View
  31. Change the captions of the DespositTypeID and DepositType to Deposit Type ID and Deposit Type respectively
  32. Close the table and, when asked whether you want to save it, click Yes
  33. To create a new form, on the main menu, click Insert -> Form
  34. In the New Table dialog box, click Form Wizard
  35. In the combo box, select DepositTypes and click OK
  36. In the first page of the wizard, click the button that selects all records and click Next
  37. In the second page of the wizard, accept the Columnar option and click Next
  38. In the third page of the wizard, accept the Standard option and click Next
  39. In the fourth page, accept the suggested name of the form as DepositTypes and click Finish
  40. Enter a few records as follows:
     
    Deposit Type ID Deposit Type Description
    1 Cash  
    2 ATM Deposit made at the Automated Teller Machine
    3 Personal Check Check written by the customer or written to the customer
    4 Business Check Examples include payroll
    5 Direct Deposit From the customer's employer or a customer's customer
    6 Transfer Money transferred to this account from another account
    7 New Account  
  41. Close the form
  42. To create a new report, on the main menu, click Insert -> Report
  43. In the New Report dialog box, click Report Wizard
  44. In the combo box, select DepositTypes and click OK
  45. In the first page of the wizard, click the button that selects all records and click Next
  46. In the second page, make sure no grouping is selected and click Next
  47. In the third page, click make sure the combo boxes are empty and click Next
  48. In the fourth page, click Columnar and click Next
  49. In the fifth page of the wizard, click Formal and click Next
  50. Accept the name of the report as AccountTypes and click Finish
  51. After viewing the report, close it
  52. While the Tables section of the Database window is displaying, right-click AccountTypes and click Save As...
  53. Set the name of the table to ChargeReasons and click OK

  54. Right-click ChargeReasons and click Design View
  55. Rename the fields as follows:
     
    Old Name New Name New Property
    AccountTypeID ChargeReasonID Caption: Charge Reason ID
    AccountType ChargeReason Caption: Charge Reason
    Description   Data Type: Memo
  56. Close the table
  57. When asked whether you want to save it, click Yes
  58. To create a new form, on the main menu, click Insert -> Form
  59. In the New Form dialog box, click AutoForm: Columnar and, in the combo box, select ChargeReasons
  60. Click OK and adjust the design of the form as you see fit. Here is an example:
     
  61. On the Form View toolbar, click the Save button
  62. Accept the suggested name of the form and click OK
  63. change the values of the records as follows
     
    Charge Reason ID Charge Reason Description
    1 Monthly Charge Applied every month to all accounts
    2 Overdraft Applied if a customer's account remains negative for 72 hours
    3 Miscellaneous Charge This charge could be applied for any reason the management judges necessary. If/When applied, an application should be noted and the customer must be notified.
  64. Close the form
  65. To create a new report, on the main menu, click Insert -> Report
  66. In the New Report dialog box, click AutoReport: Columnar
     
  67. In the combo box, select ChargeReasons and click OK
  68. Close the Report
  69. When asked whether you want to save it, click Yes
  70. Accept the suggested name of the report and click OK
  71. Close the report

Programmatically Creating a Report

To programmatically create a report, you can call the CreateReport() method of the Application object. The syntax of this method is:

CreateReport([database[, reporttemplate]])

Both arguments of this method are optional. Here is an example of calling it:

Private Sub cmdReport_Click()
    Dim rptMaintenance As Report

    Set rptMaintenance = CreateReport
End Sub

If you call the method like this, it generates a temporary report named Report1 but it doesn't save it. After the report has been generated, it appears in Microsoft Access. If you want to keep it, you can save it. If fact, if you try closing it, you would be asked whether you want to save it. If yes, you would be asked to give it a name.

The first argument of this method is the name of the database that will receive the report. If the report will be added to the current database, you can omit this argument. The second argument is the name of an existing report that you want to use as template. If you specify this argument, you must make sure that you provide the name of a report. Otherwise, you can omit it.

 

Previous Copyright © 2005-2012, FunctionX, Inc. Next