Pierakstīties, izmantojot Microsoft
Pierakstīties vai izveidot kontu
Sveicināti!
Atlasīt citu kontu.
Jums ir vairāki konti
Izvēlieties kontu, ar kuru vēlaties pierakstīties.

Piezīme.:  Mēs vēlamies sniegt jums visjaunāko palīdzības saturu jūsu valodā, cik vien ātri to varam. Šī lapa ir tulkota automatizēti, un tajā var būt gramatiskas kļūdas un neprecizitātes. Mūsu nolūks ir šo saturu padarīt jums noderīgu. Vai lapas lejasdaļā varat mums pavēstīt, vai informācija jums noderēja? Ērtai atsaucei šeit ir šis raksts angļu valodā .

You can use a formula in Microsoft Office InfoPath 2007 to automatically add a specific number of days to a date in a control on your form template.

This article explains how to add a specific number of days to a date and display the results in a control on a form by using the addDays and today functions.

Šajā rakstā

What is a formula?

A formula is an XPath expression made up of values, fields or groups, functions, and operators used to calculate and display other values. Formulas can be used to do the following tasks:

  • Calculate mathematical values from values that you specify when designing the form template or values that users enter into controls when they fill out forms based on your form template..

  • Display specific dates and times.

  • Display the values that users enter into one control in another control.

  • Set the default value of a field or control.

  • Run a rule based on a value calculated by using a formula.

Each XPath expression that is used in a formula is a combination of values, functions, and operators that evaluates to a single value. A formula can contain several expressions. You can think of a formula as a sentence made up of one or more phrases, with each phrase representing one expression in the formula.

The following illustration shows the relationship between a formula and an expression.

Formula sastāv no viena vai vairāku izteiksmes. Izteiksme ir jebkura kombinācija operatorus, lauku nosaukumi, funkcijas, literāļu un konstanšu, kas tiek novērtēts ar vienu vērtību.

A function is an expression that returns a value based on the results of a calculation. The values used in the functions are called arguments. You can use the standard XPath 1.0 functions that are included in InfoPath, as well as some InfoPath-specific functions. Find links to more information about InfoPath functions in the See also section.

Top of Page

Step 1: Insert a date picker control that displays the current date by default

The date picker control is designed explicitly for storing dates. In order to add a set number of days to a date that users enter into a control, you must first add a date picker control to your form template. You can then create a formula that uses the today function to display the current date in that control by default.

  1. On the form template, click where you want to insert the data picker.

  2. Ja uzdevumrūts Vadīklas nav redzama, noklikšķiniet uz Papildu vadīklas izvēlnē Ievietot vai nospiediet taustiņu kombināciju ALT+I, C.

  3. Under Insert controls in the Controls task pane, click Date Picker.

  4. In your form template, type Today's Date in front of the date picker control that you just inserted.

  5. Double-click the date picker control that you just inserted.

  6. Noklikšķiniet uz cilnes Dati.

  7. In the Field name box, type a name for the field.

    Padoms.: It is a good idea to use a name that describes the contents of the field. A descriptive name makes the form template easier to understand for you or anyone modifying the form template. For example, you might type dteToday.

  8. Noklikšķiniet uz Lietot.

  9. Click Insert Formula pogas attēls.

  10. Click Insert Function in the Insert Formula dialog box.

  11. Under Categories in the Insert function dialog box, click Date and Time, and then, under Functions, click today.

Top of Page

Step 2: Insert a text box that contains the addDays function

After you add the date picker control and create the formula that uses the today function, you can add a text box to your form template and create a formula that uses the addDays function.

  1. On the form template, click where you want to insert the text box.

  2. Ja uzdevumrūts Vadīklas nav redzama, noklikšķiniet uz Papildu vadīklas izvēlnē Ievietot vai nospiediet taustiņu kombināciju ALT+I, C.

  3. Under Insert controls in the Controls task pane, click Text Box.

  4. In your form template, type 30 Days Later in front of the text box control that you just inserted.

  5. Double-click the text box that you just inserted.

  6. Noklikšķiniet uz cilnes Dati.

  7. In the Field name box, type a name for the field, and then click Apply.

    Padoms.: It is a good idea to use a name that describes the contents of the field. A descriptive name makes the form template easier to understand for you or anyone modifying the form template. For example, you might type txtAdd30Days.

  8. Click Insert Formula pogas attēls.

  9. Click Insert Function in the Insert Formula dialog box.

  10. Under Categories in the Insert function dialog box, click Date and Time, and then under Functions, click addDays.

  11. Noklikšķiniet uz Labi.

  12. In the Formula box, double-click the first instance of double click to insert field.

  13. In the Select a Field or Group dialog box, click dteToday, and then click OK.

  14. Click the second instance of double click to insert field, press DELETE, and then type the number of days that you want to add to the current date. For example, if you wanted to add 30 days to today's date, you would type 30.

  15. To test that your formula is entered correctly, click Verify Formula.

    My formula contains errors

    Click Show Details in the Microsoft Office InfoPath dialog box to see the errors in the formula. The following are some suggestions for resolving these errors:

    • If you are using a function in your formula, verify that you are using the correct arguments for the function. Some functions require fields or groups while other functions require specified values as arguments. Find links to more information about functions in the See also section.

    • Delete and retype your formula to make sure that it is correctly typed.

Top of Page

Step 3: Change how the date is displayed in the text box

After you add the text box and create the formula to display the new date, you can format how the date is displayed in the text box.

  1. In the form template, double-click the text box.

  2. Noklikšķiniet uz cilnes Dati.

  3. In the Data Type list, click Date (date), and then click Format.

  4. In the Display the date like this list, click the display style that you want.

    Piezīme.: Display styles that have an asterisk will update based on the user's system settings.

  5. Lai pārbaudītu izmaiņas, standarta rīkjoslā noklikšķiniet uz Priekšskatīt vai nospiediet taustiņu kombināciju CTRL+SHIFT+B.

Top of Page

Nepieciešama papildu palīdzība?

Vēlaties vairāk opciju?

Izpētiet abonementa priekšrocības, pārlūkojiet apmācības kursus, uzziniet, kā aizsargāt ierīci un veikt citas darbības.

Kopienas palīdz uzdot jautājumus un atbildēt uz tiem, sniegt atsauksmes, kā arī saņemt informāciju no ekspertiem ar bagātīgām zināšanām.

Vai šī informācija bija noderīga?

Cik lielā mērā esat apmierināts ar valodas kvalitāti?
Kas ietekmēja jūsu pieredzi?
Nospiežot Iesniegt, jūsu atsauksmes tiks izmantotas Microsoft produktu un pakalpojumu uzlabošanai. Jūsu IT administrators varēs vākt šos datus. Paziņojums par konfidencialitāti.

Paldies par jūsu atsauksmēm!

×