About forms

An InfoMaker form is an electronic document you use to enter data in a database. The form displays existing data from your database. You can change the existing data and add new data. You can also print a form. Each form has procedures associated with it, which include common database tasks such as delete, insert, and update.

Why use a form for data entry

In InfoMaker, you can enter data in your database in two ways:

  • In the Database painter, you can preview a table, change data or insert a new row of data, and update the database

  • In the Form painter, you can run a form, change data or insert a new row of data, and update the database

If you need to add or change data in your database frequently, making changes directly in the database tables is inefficient and time-consuming. A form is designed to make data entry easier and faster.

You can design a form so that you can see all columns of data on your screen. Your design can make data easy to view on the screen and easy to read if printed. And you can create edit styles and display formats to make it easier to enter and view data.

The following illustration shows the Employee table in the PB Demo DB, which has 20 columns of data for 75 employees. When you view it in the Database painter, you can see only a few rows and columns of data at a time:

Changing data or entering data for a new employee directly in the Employee table is difficult. To see other columns, you need to scroll (or InfoMaker scrolls for you as you tab from column to column), and you can never see all the data for an employee at one time.

Instead, you could use the following form to enter or change employee data. The form uses the Freeform form style of InfoMaker. When you run the form, here is a sample of how it looks:

You can use this form to change data easily. You can also insert data for a new employee, click the Insert button, and a blank form displays. You can see all the data for each employee at one time, and with additional enhancements, the presentation of the data can be improved for printing.

About the PainterBar of the Form painter

The PainterBar of the Form painter provides buttons for performing common activities you might do when creating or altering a form definition. There is also a menu item corresponding to most buttons.

Creating new forms

When you create a new form with InfoMaker, you always specify the data source and form style of the form. Then you define the data for the form, and InfoMaker generates the basic form.

Once you have the basic form, you can name the form and save it. Then you can continue to enhance the form to make it easier to use.

The following discussion introduces you to a few form concepts and terms. When you are ready to create a particular type of form, you can follow the steps for the type.

New Form dialog box

You specify the data source and form style in the New Form dialog box:

Data sources

The data source you use determines how InfoMaker retrieves data for your form. You can select one of three data sources when you create a form:

Data source

Pick this data source when

Quick Select

The data is from tables that are connected through a key, and you need only to sort and limit the data.

SQL Select

The data is from tables that are not connected through a key, or you want more control over the SQL SELECT statement generated for the data source.

Query

The data has been defined as a query.


For master/detail forms

You always use the Quick Select data source for master/detail forms.

For complete information about data sources, see Selecting a data source.

Form styles

A form style is a predefined way of presenting and processing information in a form. Each form you build in InfoMaker is based on an existing form style.

InfoMaker provides four built-in form styles:

Form

What it shows

Freeform

One row of data at a time

Grid

Rows of data in a grid

Master/Detail One-To-Many

One item in a freeform area at the top and a grid with details about the item at the bottom

Master/Detail Many-To-One

Many items in a grid at the top and a freeform area with details about an item at the bottom


In addition to the built-in form styles, PowerBuilder developers in your organization can develop custom form styles to meet your organization's needs. Custom form styles also display in the New Form dialog box.

For information about creating custom form styles, talk to PowerBuilder developers in your organization.

Actions in a form style

Each form style has a set of predefined actions. An action is a procedure you can attach to buttons you place in a form. Usually a style includes the common database actions (insert, update, and delete rows). Each of the built-in form styles of InfoMaker has these database actions and additional actions that are useful and appropriate to the form style.

For example, you can place a button in a form and then attach the Print action to it. After you run the form, you can print the current data by clicking the button:

Actions are also available through the toolbar and menu items when you run a form.

Freeform forms

You use freeform forms for basic data maintenance.In freeform forms, you see one row of data at a time. You can arrange the information any way you want. When you run the form, you can add, modify, and delete rows of data.

For example, the following form is a freeform form that allows you to view and update customer information. This form uses all columns in the Customer table in the PB Demo DB.

After a few enhancements have been made to the basic form, here is the freeform form with data:

Grid forms

You use grid forms for basic data maintenance where you want to be able to view and update more than one row of data at a time.

The data in a grid form displays in a rigid grid. When running a grid form, you can resize and reorder columns.

For example, the following form is a grid form that allows you to view information for many customers at a time.

This form uses all columns in the Customer table in the PB Demo DB:

Working in a grid form

When you design and run a grid form, you can resize and reorder columns.

To resize a column:

  1. Position the pointer at a column boundary.

    The pointer changes shape to a 2-headed arrow.

  2. Drag the mouse to move the boundary.

  3. Release the mouse button when the column is the correct width.

To reorder columns:

  1. Select a column heading.

    InfoMaker selects the column and displays a line representing the column border:

  2. Drag the column left or right.

  3. Release the mouse button to drop the column into place.

Master/Detail One-To-Many forms

Frequently, you may have data in one table that is related to data in another table in a one-to-many relationship. For example:

  • You maintain information about departments and their employees. In one department there are many employees. That is, there is a one-to-many relationship between departments and employees.

  • You maintain information about your customers and their orders. One customer typically has many orders. There is a one-to-many relationship between customers and orders.

You may want to display this type of relationship in a form. Such a form is called a master/detail one-to-many form.

For example, the following form displays information about one department at the top and all of the employees of that department at the bottom:

About the ID column

Note the ID of the department in the master table at the top of the form. Although you cannot see the ID of the department in the detail table at the bottom of the form, it is there. The ID has been hidden by moving grid boundaries to cover the ID column. Since all the ID values are the same, hiding the values is useful.

If the detail table did not include the ID, the form would not be updatable. If you forget to include necessary columns, InfoMaker prompts you.

The following illustration shows the database tables that handle the data on this form: the Department table and the Employee table in the PB Demo DB. The Department table is the master table, and the Employee table is the detail table.

Note that there is a primary/foreign key relationship between the tables: the Dept_id column in the Employee table has the same values as the Dept_id column in the Department table:

Master/Detail Many-To-One forms

You might have a lot of information about a particular class of entities, such as customers, employees, or parts. You might want to be able to scroll easily through a list of the entities (the many), then see the details for one of them. You do that in a master/detail many-to-one form.

Typically, you select one or two columns for the master table (enough for you to identify the entity, such as customer or employee) and the rest of the columns pertaining to the entity for the detail table.

Selecting columns for the master and detail areas

In a master/detail many-to-one form, you usually pick one or two columns for the master area and many columns for the detail area, and you change data or insert new data in the detail area only. The data in the master area is usually updated with a different form. To be able to insert new rows in the master area or detail area, you must include all columns that have been defined in the database as requiring values.

For information about defining data so that a form can update a database, see Defining data so that a form can update a database.

For example, the following form lists all customers at the top (the master area) and the details for the selected customer at the bottom (the detail area):

Both the master and detail areas use the Customer table in the PB Demo DB. The Company_name and Id columns were chosen for the master table, and all columns were chosen for the detail table.

About the Id column

Since the Id column is the primary key, you must select the Id column to make the detail part for the form updatable, but you can delete it from the detail part.