Description

Allows printing data from a database.


The setting of the Report button is almost the same as the setting of the Search button, since in fact both actions search the database and then display the search result, only in our case we will see the search result when printing. After setting up the button, you need to call the report designer to create a template, which will determine exactly how the document will look when printed, but everything in order.


As an example, we will print a simple list of clients. It will look as shown in the picture:






The setting of the "Report" button is shown in the figure below:




Let's consider this setting in detail by steps:


  1. Select the components involved in the search

This list is empty, so the report will contain data on all clients that are present in the database. If necessary, you can add components that will only include clients that meet your criteria in the report.



  1. Select the database table for the query

We will print information about the client, respectively select the "clients" database table.



  1. The result

Select the table fields that we need in the report.



  1. Select report file

Since the report template has yet to be created, this setting should select "Open report designer...".

A report template is a file that defines exactly what the report will look like, this file will be created in the report designer and will be saved in the Report folder of your project.

.




A nuance worth noting here. As you can see from the settings in p.2, to generate the result we select fields from 2 different tables (clients and category), as a rule, in other programs you need to write an SQL query, which manually specifies how one table, links to another table and in what sequence.


The program My Visual Database tries to understand by itself how tables should be linked to each other in order to get exactly the data you expect, thus saving you from the need to learn the SQL query language.


Unfortunately, it is not always possible for the program to predict how tables should be linked to get the data you would like to see. Such a situation can occur when you need to link 3 or more tables and if there are no obvious links between them.


What should we do? On the "Database tables" tab, under each table, there is a checkbox "The table is a dictionary". On this tab, you should note which tables in your project are dictionaries. But how to understand which tables are dictionaries?


Examples of dictionary tables are the table containing country names, Statuses (Open, Closed), Types (Legal Entity, Physical Entity), name with prices, etc.


That is, such tables, which, as a rule, are filled in first at the start of work with the database and are not edited or edited rarely in the future.


In this case, the dictionary table can be referred to the "category" (client category), for this table you need to check the "Table is a dictionary" box under these tables, so you will help the program to link the tables correctly.





To create a report template, you need to run the project

In the launched project, click this button with the report action, so you will open the report designer.


This report will be a bit more complicated than the previous one, as it will use so-called blocks (or Band). Blocks allow you to create almost any report structure. Some of them we will now get acquainted with.


To view all available blocks, click on the left icon , then you will see a menu as shown in the figure below









Let's start creating a report using blocks and find out what they are for.


From the menu shown in the figure above, select the Report Title block and this block will appear in the report. The information in this block will be printed only on the first page of your report.


Place the logo and company information in this block. As a result, you should succeed as shown in the figure below:


You can skip this block if you do not need a title for your report.





Place the next Page Header block. The information placed in this block will be displayed on each printed page (in case your report does not fit on one page).


In this block we will place the information about the client. We will also place the headers for the table which will be located in the next block.

Place the text and data fields in this block as shown in the picture below:






The next block to be placed in the report is Master Data.


This block is designed to output information in the form of a table. With this block we will get a table where we will see the list of clients.


Place this block in the report by selecting it from the menu. Before it appears in the report, you will see a window with the title Select DataSet, in which you need to select the data source. Select a data source from the list with the title Report and click OK.


In this block, place the database fields that you need in the table. As a result, you will see, as shown in the figure below:







And the last block that we will place in the report is PageFooter, this block will be printed on each page of the report, we use it to numerate the pages.


Place the Page# system variable in this block from the right side of the report designer (Variables tab), just drag and drop:




Now your report template is fully ready




Go to the File > Preview menu or just press Ctrl+P to see what your report will look like.


Save the report template to the Report folder of your project, menu File > Save As...  Give the file a name such as "clients" as shown in the figure below:




It remains to go back to the settings of this button and select this report template to use for printing:





Here we go. Now you can start the project again and click on this button, after which you will see a print-ready report with a list of clients.



Documentation on working with the report designer can be found here https://www.fast-report.com/public_download/UserManual-en.pdf