|
Using Date Time and Formatted Controls in Forms
From NeoWiki
Revision as of 17:55, 12 October 2007 (edit) Lorinda (Talk | contribs) (→Date Controls - finish article) ← Previous diff |
Current revision (11:08, 29 March 2008) (edit) (undo) ( | contribs) m (→Formatted Field Controls - typo - replace] with } point 9) |
||
(6 intermediate revisions not shown.) | |||
Line 8: | Line 8: | ||
==Date Controls== | ==Date Controls== | ||
- | #Click on the text box under the Date label of the form. If the box and the label are selected, go to the {{Menu|Format}} menu and choose {{Menu|Group}} and then {{Menu|Ungroup}}. Then click elsewhere on the form to unselect the two items. | + | #There are two ways to access the Date Control properties: |
- | #Double click the text box under the Date label of the form. | + | ##Click on the text box under the Date label of the form. |
+ | ##:If the box and the label are selected, go to the {{Menu|Format}} menu and choose {{Menu|Group}} and then {{Menu|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 | ||
+ | ##Click on the {{Button|Form Navigator}} on the Form Design toolbar. The {{Window|Form Navigator}} window opens. | ||
+ | ##:Right-click or control-click on the name of the date control in the {{Window|Form Navigator}} window. | ||
#If the {{Window|Properties}} window that opens is titled {{Window|Properties: Text Box}}, close the window. | #If the {{Window|Properties}} window that opens is titled {{Window|Properties: Text Box}}, close the window. | ||
- | #:Control click the text box for the date field and select {{Menu|Replace With}} and then {{Menu|Date Field}} | + | #:If you are working in directly in the form, do the following: |
- | # | + | ##Control click the text box for the date field and select {{Menu|Replace With}} and then {{Menu|Date Field}} |
+ | ##Then double click on the field to open the {{Window|Properties}} window. | ||
+ | #:If you are using the Form Navigator, do the following: | ||
+ | ##Control-click or right-click on the name of the field and choose {{Menu|Replace With}} and then {{Menu|Date Field}}. | ||
+ | ##Then control-click or right click on the field name again and choose {{Menu|Properties}} to reopen the {{Window|Properties}} window. | ||
#The {{prefName|Date Format}} field lets you choose from several date formats | #The {{prefName|Date Format}} field lets you choose from several date formats | ||
- | #The {{prefName|Date min}} and {{prefName|Date max}} fields let you set minimum and maximum dates. They do not need to be | + | #The {{prefName|Date min}} and {{prefName|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. |
#Set the {{prefName|Dropdown}} to {{prefName|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. | #Set the {{prefName|Dropdown}} to {{prefName|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. | ||
#Close the {{Window|Properties}} window. | #Close the {{Window|Properties}} window. | ||
Line 21: | Line 30: | ||
==Time Controls== | ==Time Controls== | ||
- | #Click on the text box under the Start Time label of the form. If the box and the label are selected, go to the {{Menu|Format}} menu and choose {{Menu|Group}} and then {{Menu|Ungroup}}. Then click elsewhere on the form to unselect the two items. | + | #Click on the text box under the Start Time label of the form. If the box and the label are selected, go to the {{Menu|Format}} menu and choose {{Menu|Group}} and then {{Menu|Ungroup}}. Then click elsewhere on the form to unselect the two items. '''Or,''' you can use the Form Navigator, as described in [[#Date Controls|Date Controls]] above. |
#Double click the text box under the Start Time label of the form. | #Double click the text box under the Start Time label of the form. | ||
#If the {{Window|Properties}} window that opens is titled {{Window|Properties: Text Box}}, close the window. | #If the {{Window|Properties}} window that opens is titled {{Window|Properties: Text Box}}, close the window. | ||
#:Control click the text box for the date field and select {{Menu|Replace With}} and then {{Menu|Time Field}} | #:Control click the text box for the date field and select {{Menu|Replace With}} and then {{Menu|Time Field}} | ||
- | # | + | #:Then double click on the field to open the {{Window|Properties}} window. |
+ | #:You can also use the Form Navigator to replace the control type. See this same step in [[#Date Controls|Date Controls]] above. | ||
#The {{prefName|Time Format}} field lets you choose from several time formats | #The {{prefName|Time Format}} field lets you choose from several time formats | ||
- | #The {{prefName|Time min}} and {{prefName|Time max}} fields let you set minimum and maximum times. They do not need to be | + | #The {{prefName|Time min}} and {{prefName|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. |
#Close the {{Window|Properties}} window. | #Close the {{Window|Properties}} window. | ||
Line 35: | Line 45: | ||
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. | 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. | ||
- | #Click on the text box under the End Time label of the form. If the box and the label are selected, go to the {{Menu|Format}} menu and choose {{Menu|Group}} and then {{Menu|Ungroup}}. Then click elsewhere on the form to unselect the two items. | + | #Click on the text box under the End Time label of the form. If the box and the label are selected, go to the {{Menu|Format}} menu and choose {{Menu|Group}} and then {{Menu|Ungroup}}. Then click elsewhere on the form to unselect the two items. '''Or,''' you can use the Form Navigator, as described in [[#Date Controls|Date Controls]] above. |
- | #Right-click or control click on the text box under the End Time label and choose {{Menu|Replace with}} and then {{Menu|Formatted Field}} from the contextual menu. | + | #Double click the text box under the Start Time label of the form. |
+ | #Right-click or control click on the text box under the End Time label and choose {{Menu|Replace with}} and then {{Menu|Formatted Field}} from the contextual menu. | ||
+ | #: You can use the Form Navigator to replace the control type. With the {{Window|Form Navigator}} window open, right-click or control-click on the name of the control you want to replace and choose {{Menu|Replace with}} and then {{Menu|Formatted Field}}. | ||
#Double click on the text box under the End Time label. The {{Window|Properties: Formatted Field}} window will open. | #Double click on the text box under the End Time label. The {{Window|Properties: Formatted Field}} window will open. | ||
#Click on the {{Button|...}} button to the right of the text field labeled {{prefName|Formatting}} | #Click on the {{Button|...}} button to the right of the text field labeled {{prefName|Formatting}} | ||
Line 42: | Line 54: | ||
#Click on each of the options listed in the {{Section|Category}} column, and look at how the other options in this window change. For example, both the {{prefName|Date}} and {{prefName|Time}} options let you either choose from a format listed in the {{Section|Format}} section '''or''' define your own format in the {{prefName|Format Code}} text box. | #Click on each of the options listed in the {{Section|Category}} column, and look at how the other options in this window change. For example, both the {{prefName|Date}} and {{prefName|Time}} options let you either choose from a format listed in the {{Section|Format}} section '''or''' define your own format in the {{prefName|Format Code}} text box. | ||
#Now click on the {{prefName|Time}} option under {{Section|Category}} to set the format for time | #Now click on the {{prefName|Time}} option under {{Section|Category}} to set the format for time | ||
- | #Choose a format in the {{Section|Format}} section or create a | + | #Choose a format in the {{Section|Format}} section or create a custom time format. I started by clicking on {{prefName|01:37 PM}} under {{Section|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 {{prefName|User Defined}} category. |
#Click the {{prefName|OK}} button to close the window | #Click the {{prefName|OK}} button to close the window | ||
#Close the {{window|Properties}} window. | #Close the {{window|Properties}} window. | ||
Line 49: | Line 61: | ||
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). | 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). | ||
+ | |||
+ | {{botlangbarEN|[[Fr:Utiliser les Contrôles de Date, Heure et Autres Champs Formatés dans les Formulaires|Français]]}} |
Current revision
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
- There are two ways to access the Date Control properties:
- 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
- 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.
- Click on the text box under the Date label of the form.
- 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:
- 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.
- If you are using the Form Navigator, do the following:
- Control-click or right-click on the name of the field and choose Replace With and then Date Field.
- Then control-click or right click on the field name again and choose Properties to reopen the Properties window.
- The Date Format field lets you choose from several date formats
- 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.
- 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.
- 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
- 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.
- Double click the text box under the Start Time label of the form.
- 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.
- The Time Format field lets you choose from several time formats
- 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.
- 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.
- 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.
- Double click the text box under the Start Time label of the form.
- 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.
- Double click on the text box under the End Time label. The Properties: Formatted Field window will open.
- Click on the ... button to the right of the text field labeled Formatting
- A Number Format window very similar to the one found in Calc or Writer tables opens.
- 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.
- Now click on the Time option under Category to set the format for time
- 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.
- Click the OK button to close the window
- 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).