Using Date Time and Formatted Controls in Forms

From NeoWiki

Revision as of 09:34, 14 October 2007 by Jgd (Talk | contribs)
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

Date Controls

  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.
  2. Double click the text box under the Date 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 Date Field
    Then double click on the field to open the Properties window.
  4. The Date Format field lets you choose from several date formats
  5. The Date min and Date max fields let you set minimum and maximum dates. They do not need to be chagned for this application, but there are some situations in which setting these differently could be helpful.
  6. 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.
  7. 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.

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.
  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.
  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 chagned 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.

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.
  2. 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.
  3. Double click on the text box under the End Time label. The Properties: Formatted Field window will open.
  4. Click on the ... button to the right of the text field labeled Formatting
  5. A Number Format window very similar to the one found in Calc or Writer tables opens.
  6. 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.
  7. Now click on the Time option under Category to set the format for time
  8. Choose a format in the Format section or create a cutom time format. I started by clicking on 01:37 PM under Format and then editing the entry in the {{prefName|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.
  9. Click the OK button to close the window
  10. Close the Properties window.

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