Using Date Time and Formatted Controls in Forms

From NeoWiki

Jump to: navigation, search
This article is part of the To Base and Back Again tutorial series.

Base includes a wide variety of form controls for the forms you create. Date, Time, and Formatted fields allow you to have more control over the formatting of these types of data than a plain text field. The following article works with the Field Trips Data Entry form created in the Creating A Data Entry Form With A Subform tutorial.

Note: the Form Wizard appears to be somewhat inconsistent about when it creates date and time controls for fields defined as date or time fields. Sometimes you will need to replace form controls and sometimes you will not.

Open the Field Trips Data Entry form by control-clicking on it in the main database document window and choosing Edit from the contextual menu. (You will need to have selected Forms from the left hand column first).

Contents

[edit] Date Controls

  1. There are two ways to access the Date Control properties:
    1. Click on the text box under the Date label of the form.
      If the box and the label are selected, go to the Format menu and choose Group and then Ungroup. Then click elsewhere on the form to unselect the two items.
      Double click the text box under the Date label of the form.
      OR
    2. Click on the Form Navigator on the Form Design toolbar. The Form Navigator window opens.
      Right-click or control-click on the name of the date control in the Form Navigator window.
  2. If the Properties window that opens is titled Properties: Text Box, close the window.
    If you are working in directly in the form, do the following:
    1. Control click the text box for the date field and select Replace With and then Date Field
    2. Then double click on the field to open the Properties window.
    If you are using the Form Navigator, do the following:
    1. Control-click or right-click on the name of the field and choose Replace With and then Date Field.
    2. Then control-click or right click on the field name again and choose Properties to reopen the Properties window.
  3. The Date Format field lets you choose from several date formats
  4. The Date min and Date max fields let you set minimum and maximum dates. They do not need to be changed for this application, but there are some situations in which setting these differently could be helpful.
  5. Set the Dropdown to yes. This creates a drop-down button in the entry field. Users can click on the drop down and a calendar will appear, allowing them to select a particular date.
  6. Close the Properties window.

Note: If you are creating a form in design view, you can choose a date control by clicking on the More controls button on the Form Controls toolbar. A floating window will open with additional form controls, including the date control. If you use date controls often, you can customize the toolbar to include the date control.

[edit] Time Controls

  1. Click on the text box under the Start Time label of the form. If the box and the label are selected, go to the Format menu and choose Group and then Ungroup. Then click elsewhere on the form to unselect the two items. Or, you can use the Form Navigator, as described in Date Controls above.
  2. Double click the text box under the Start Time label of the form.
  3. If the Properties window that opens is titled Properties: Text Box, close the window.
    Control click the text box for the date field and select Replace With and then Time Field
    Then double click on the field to open the Properties window.
    You can also use the Form Navigator to replace the control type. See this same step in Date Controls above.
  4. The Time Format field lets you choose from several time formats
  5. The Time min and Time max fields let you set minimum and maximum times. They do not need to be changed for this application, but there are some situations in which setting these differently could be helpful.
  6. Close the Properties window.

Note: If you are creating a form in design view, you can choose a time control by clicking on the More controls button on the Form Controls toolbar. A floating window will open with additional form controls, including the time control. If you use time controls often, you can customize the toolbar to include the time control.

[edit] Formatted Field Controls

Sometimes you want more control over fields than the date or time control fields offer. When this is the case, formatted field controls are a good option. We will use a formatted field with the EndTime field, just to see what options are available there.

  1. Click on the text box under the End Time label of the form. If the box and the label are selected, go to the Format menu and choose Group and then Ungroup. Then click elsewhere on the form to unselect the two items. Or, you can use the Form Navigator, as described in Date Controls above.
  2. Double click the text box under the Start Time label of the form.
  3. Right-click or control click on the text box under the End Time label and choose Replace with and then Formatted Field from the contextual menu.
    You can use the Form Navigator to replace the control type. With the Form Navigator window open, right-click or control-click on the name of the control you want to replace and choose Replace with and then Formatted Field.
  4. Double click on the text box under the End Time label. The Properties: Formatted Field window will open.
  5. Click on the ... button to the right of the text field labeled Formatting
  6. A Number Format window very similar to the one found in Calc or Writer tables opens.
  7. Click on each of the options listed in the Category column, and look at how the other options in this window change. For example, both the Date and Time options let you either choose from a format listed in the Format section or define your own format in the Format Code text box.
  8. Now click on the Time option under Category to set the format for time
  9. Choose a format in the Format section or create a custom time format. I started by clicking on 01:37 PM under Format and then editing the entry in the Format Code text box from HH:MM AM/PM to H:MM AM/PM so that there would not be a leading zero in the hour column. Note that this shifted the field to the User Defined category.
  10. Click the OK button to close the window
  11. Close the Properties window.

[edit] Other Related Controls

There are also Currency, Numeric, and Pattern controls that work similarly. Currency and Numeric controls are pretty much self explanatory. The Pattern control is for text entry, and allows you to control the patter of entry. For example, if you had a part number field where part numbers had the pattern letter letter - four digit number, you could restrict entry to that type of pattern, and provide the hyphen automatically. For more information, look at the entries on Edit Mask and Literal Mask in the NeoOffice help. (you want the entries under General rather than under More Controls in the help).


This article in other languages: Français
Personal tools