Page 366
Figure 13.17.
Aligning a groupof
items.
Let's work on the column headings now. Because the text items in the Class block have been redistributed horizontally, you may need to reposition the column headings.
Figure 13.18. Page 367
Layout of master-
detail form.
You are probably anxious to see the result of all this work. The best way to determine if the form is properly designed is to test it. Do this either by selecting File | Run from the menu or by pressing the green signal on the horizontal toolbar. First, the Forms Designer will generate an FMX file that can be executed. If there are no errors, the Forms Designer will invoke Forms Runtime to run the FMX file. You should see a window labeled Developer/2000 Forms Runtime for Windows 95/NT [WINDOW0]. Within that window, you should see another window labeled WINDOW0. Maximize both windows. Figure 13.19 shows what your screen should look like.
Figure 13.19.
Initial window when
running the master-
detail form.
To run a query, click on the Query button twice; the first click enables you to enter query criteria and the second click executes the query. As you can see, the departments are not in any particular order. Also, the classes that belong to a department are not in any specific order either. In the next section, you'll change the Order By property for the master and detail blocks. To do this, exit Forms Runtime by selecting File | Exit.
In the Forms Designer, go to the Object Navigator window by selecting Window | Object Navigator from the menu. Select the Department block, and right-click Properties. Scroll down to the Order By property and enter Department_ID (see Figure 13.20). Press Enter for the property to be set.
Page 368
Figure 13.20.
Setting the Order By
property for the
Department block.
Select the Class block, and right-click Properties. It probably makes more sense to order the block by Course_ID rather than Class_ID because the Course ID is a familiar number to everyone: administrators, instructors, and students. Again, scroll down to the Order By property, and enter Course_ID. Press Enter for the property to be set.
There are several other things that should be changed in the form. First of all, some fields are too widenamely, Class_ID, Schedule_ID, and Class_Room. One field is too narrow: Class_Building. Also, it probably would make more sense to put Course_ID directly to the right of Class_ID. Let's make these changes and run the form again.
Execute a query and scroll to the history department by clicking on > or by selecting
Record | Next from the menu until you see the history department displayed in
the Department block (see Figure 13.21).
If you want to change the room where Class 108400 (history course 115) is going to be held, you need to navigate to the Class block. By default, the current block is the first block, which happens to be Department. To go to the next block, press Ctrl+PageDown. However, when you do this, you'll notice that the focus is set to the left-most button on the Button Palette. This behavior can be explained by the order of the blocks.
If you use the Object Navigator to view the blocks, you'll notice that the blocks are in the order of Department, Button_Palette, and Class (see Figure 13.22); that is the order in which the blocks are navigated with the Next Block command. To change the order of the blocks, select a block and drag it until the pointer is over the block that you want to precede the
Page 369
selected block. For instance, to reposition the Class block, select it with the mouse
and, holding down the left mouse button, position the pointer over the Department block
and release the left mouse button.
Figure 13.21.
Viewing classes offered
by the history depart-
ment.
Figure 13.22.
Viewing the order of
the blocks with the
Object Navigator.
Page 370
If you navigate to the Class block, you can move to the next item by pressing the Tab key. You can move to the previous item by pressing Shift+Tab. Notice that when the focus is on the Class_ID item, pressing Tab moves the focus to Schedule_ID. When you moved Course_ID to the right of Class_ID, the tab order of the fields didn't change. The most convenient way to change the tab order is to use the Object Navigator. Figure 13.23 shows the existing order of the items in the Class block.
Figure 13.23.
Viewing tab order of
items in the Class
block.
To make Course_ID the second tab item in the block, select it with the mouse and, holding down the left mouse button, position the pointer over the Class_ID item and release the left mouse button.
Let's think of other ways that this master-detail form can be improved. One way is to use
an LOV for items that have a discrete set of values. For instance, Course_ID should be
restricted to the values of Course_ID for the current Department_ID as found in the Course table.
To create the LOV for Course_ID using the Object Navigator, select the LOVs node and
click on + on the vertical toolbar. A window will appear in which you enter the query that you
want executed for the new LOV. Actually, the Forms Designer will create a new record
group based on the query that you enter. Figure 13.24 contains the text of the query. Notice
that the Department_ID is restricted to the value contained in the Department_ID item in
the Department block. Click OK to create the LOV.