Entering Data Through Forms

Now that you know how to create a form, let's learn how to use it to enter and modify data. First, open the Plants form by clicking the Forms shortcut on the Object bar and double-clicking Plants in the Database window. You'll see that some of the user interface for a form resembles the user interface you've already seen for tables and queries, but there are new things here as well. The form shown in Figure 8.13 can tell you a lot, such as

Figure 8.13. A basic form can give you a lot of information about your data.

graphics/08fig13.gif

  • The title bar displays the form's name and purpose.

  • The record selector points out the active record. The sample form displays only one record at a time, but that isn't always the case. For example, in the subform in Figure 8.10 you can see more than one record at a time. On this form, the current record is for Black-eyed-Susan.

  • The navigation bar displays the number of records and enables you to browse through those records. The current record is the first record of seven.

Navigating Fields and Records

In a table or query, you might refer to a particular column of data as a field . Forms use controls to display data. Right now the form displays the records you entered directly into the Plants table in earlier chapters.

When you open a form, Access selects the first control in the form. For instance, when you open the Plants form, Access selects the CommonName controlyou can tell because the actual entry is highlighted. To move from one control to the next , you simply press the key. Sometimes the Enter key performs the same function, but not always, so the preferred method is the Tab key. For example, press the Tab key once to select the LatinName control. Then, press Enter to select the Notes control. While in the Notes memo field, pressing Enter simply moves the insertion point to the next line in the memo field. To move to the next control, the Picture control, you must press the Tab key. Table 8.1 lists helpful keystroke combinations for navigating a form, and Table 8.2 contains combinations for navigating in a form with a subform.

Table 8.1. Keyboard Shortcuts for Navigating Controls

Press

Result

F5+number

Selects a specific record

Tab

Moves to the next field

Shift+Tab

Moves to the previous field

End

Moves to the last field in the current record

Ctrl+End

Moves to the last field in the last record

Home

Moves to the first field in the current record

Ctrl+Home

Moves to the first field in the first record

Ctrl+Page Down

Moves to the current field in the next record

Ctrl+Page Up

Moves to the current field in the previous record

Table 8.2. Keyboard Shortcuts for Navigating Between a Main Form and a Subform

Press

Result

Tab

Enters the subform from the field that precedes the subform in the main form

Shift+Tab

Returns to the subform from the field following the subform in the main form

Ctrl+Tab

Exits the subform and moves to the next field in the main form or next record

Ctrl+Shift+Tab

Exits the subform and moves to the field that precedes the subform in the main form or previous record

Did you notice that the Notes control displayed a scrollbar when you selected it? That's because that control is based on a memo data type (at the table level). We chose that data type because it can store a lot more text than the normal text data type.

When you're ready to see the next record, simply click the Next Record button on the navigation bar. Or, keep pressing the Tab key until the last control is selected, which in this case is the CatalogName control. Then, press Tab one more time. When you do, Access displays the next recordCalendula.

Entering data is simple: Just select a field and type the data. When you're done, you press Tab or Enter, as the case may be. Because the Calendula record is current, select the Notes control and enter the following text: This plant loves cooler weather and full sun but will tolerate a hot spot if you keep well watered. You can expect lots of blooms well into fall . When you're done, press Tab to select the Picture control.

Figure 8.14. Browse to the graphic file that you want to display with the current record.

graphics/08fig14.gif

Right now, none of your records are displaying pictures, but you can fix that by following these steps:

  1. With the Picture control selected, select Object from the Insert menu. (You can also right-click the Picture control and select Insert Object from the resulting submenu.)

  2. Click the Create from File option.

  3. Click the Browse button and locate the picture file you want to display. We recommend you store pictures in the same folder with your database. When you find the correct graphics file, double-click it. Or, select it and click OK . Access will display the selected graphic file in the File control. Click the Link option only if you plan to modify the graphic file. In this case, you won't be modifying the pictures, so don't select it.

  4. Click OK .

  5. The control will probably display a small version of the file in the upper-left corner, as shown in Figure 8.15. If this happens, click the Properties button on the Form view toolbar.

    Figure 8.15. Sometimes, the control displays a small version of the file.

    graphics/08fig15.jpg

  6. In the Properties list for the Bound Object Frame, open the Size Mode properties drop-down list and select Stretch , as shown in Figure 8.16. The default is Clip.

    Figure 8.16. Select the Stretch Size Mode property.

    graphics/08fig16.jpg

  7. Close the Properties window, and the control should display a full view of the file. You'll learn more about control properties in Chapter 13.

  8. Repeats steps 14 to embed pictures of each plant.

  9. When you're done, close the form and save it when prompted. You're not saving the data you just entered; Access automatically saves the new picture data. Remember during step 6 when you changed the Size Mode property? That's what you're saving now.

Note

graphics/note.gif

Did you notice that the CommonName label to the left of that control isn't completely visible? (Depending on your system's display properties, this might not occur in your form, so don't worry if it doesn't.) That's just one of the small annoyances you'll run into when using a wizard; it simply didn't allow enough room. In Chapter 13, you'll learn how to modify controls that don't behave the way you want them to.


You might be curious about how a picture looks in datasheet view, so open the Plants table after you enter a few (or all) of the picture files. Figure 8.17 shows the Plants table after inserting a picture for each record. Each picture entry is a bitmap image. A table doesn't actually display a picture the same way a form or report does.

Figure 8.17. Graphic files appear as text in datasheet view.

graphics/08fig17.gif

Of course, you won't always be adding data. Sometimes you'll delete data or replace an entry with something new. Fortunately, it's all very easy in a form. When you select a control, the form automatically highlights the entry. At this point, you can do any of the following:

  • Press Delete to delete the entry.

  • Start typing to replace the entry.

  • Use the mouse to precisely position the insertion point so you can change one or just a few characters in the existing entry.

When you're editing records, the record selector you saw earlier changes to the small pencil icon, just as it does on a datasheet (refer to Figure 8.15). You can demonstrate this by selecting the LatinName control and pressing the Delete key. If you try this yourself, press Esc to cancel the delete task so that you don't lose data.

Note

graphics/note.gif

Graphic files vary greatly, and there's no way to guarantee the quality of each file from record to record. You can improve a picture, but that's a bit beyond the scope of this chapter.


Adding and Deleting Records

In the previous section, you learned how to enter and delete new data. Occasionally, you'll need to add or delete an entire record. You can add records in four ways:

  • Click the New Record button on the form's navigation bar, as mentioned earlier.

  • Click the New Record button on the Form view toolbar.

  • Select New Record from the Insert menu.

  • Press Ctrl++.

All the previous methods display a blank record. Notice that the record number control in the navigational control displays the number 8 you will be entering the eighth record. As soon as you begin to enter data, Access updates the record selector to display the editing symbol (the pencil icon).

Let's walk through the process of creating a new record. Do the following:

  1. With the CommonName control selected, enter French Lavender and press Tab .

  2. Enter Lavandula stoechas and press Tab three times.

  3. Open the TypeID control's drop-down list and select Decorative ; then press Tab .

  4. Enter Richters .

  5. Save the record by selecting Save Record from the Records menu, pressing Shift+Enter, or simply moving to another record. Figure 8.18 shows the new record.

    Figure 8.18. You haven't entered a picture of your new plant yet.

    graphics/08fig18.gif

Tip

graphics/tip.gif

If you change your mind while you're entering a record, you can press Esc twice to delete the record before it's saved.


Deleting a record is even easier. After selecting the appropriate record in your form, use one of the following methods to delete that record:

  • Select the Record Selector, and then press the Delete key.

  • Select Delete Record from the Edit menu.

  • Click the Delete Record button on the form view toolbar.

After you attempt to delete the record, Access displays a confirmation message. You'd click Yes to delete the record, or you'd click No to cancel the delete task. Right now, click No because you don't want to delete the record.



Absolute Beginner's Guide to MicrosoftR Access 2002
Absolute Beginner's Guide to MicrosoftR Access 2002
ISBN: N/A
EAN: N/A
Year: 2002
Pages: 133

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net