formulavalue(

formulavalue(DATABASE

, FORMULA

)
The** formulavalue( **function calculates the result of a formula based on data in the current record of any open database. This is similar to the fieldvalue( function, but allows any formula to be used, rather than just a single field.

**Parameters**

This function has two parameters:

** database** – is the database that you want to grab data from. This database must be currently open. If this parameter is

`""`

or omitted then the current database will be used.** formula** – is the formula to be used to retrieve data. If the formula is specified inline in the function itself, it must be quoted (see Quotes). Otherwise, you can pre-store the formula in a field or variable.

**Description**

The function returns data from the specified database. This is similar to the superlookup( function, but the *formulavalue(* function does not search for the data, it simply uses whatever data is in the currently active record of the specified database.

This example grabs the current address from a Mailing List database, in mailing label format.

```
formulavalue("Mailing List",{First+" "+Last+cr()+Address+cr()+City+", "+State+
" "+Zip+sandwich(cr(),Country,"")}
```

If you want to evaluate the formula based on the current database, you can omit the database parameter, like this:

```
formulavalue({First+" "+Last})
```

You may wonder why you would ever do this, since the formula above could more simply be calculated like this:

```
First+" "+Last
```

The benefit of the formulavalue function is that it allows the formula to be changed on the fly, perhaps stored in a field or variable.

```
letfileglobal nameFormula = {First+" "+Last}
...
...
...
message formulavalue(nameFormula)
```

Now the calculation can be modified at any time, or even edited with a Text Editor Object.

**See Also**

- Arithmetic Formulas -- mathematical operators and functions.
- Characters and Unicode Values -- working with individual characters of text.
- Constants -- values embedded into a formula.
- convertvariablestoconstants -- converts all of the variables in a formula into constant values.
- Date Arithmetic Formulas -- performing calculations on dates, and converting between dates and text.
- Formula Workshop -- formula workshop wizard for testing and experimenting with formulas.
- formulacalc -- allows you to evaluate a formula that you were not able to code into the procedure when it was being written.
- formulafields( -- returns a list of fields used in a formula.
- formulaidentfiers( -- returns a list of identifiers (fields and variables) used in a formula.
- Formulas -- basics of formulas: components and grammar.
- formulavalue -- calculates the result of a formula. Usually this is done with an assignment statement (for example `x=2 * y` ), but the *formulavalue* statement gives you more flexibility. You can specify what database is to be used for the calculation (an assignment statement always uses the current database) and you can specify the formula using a variable, making it easy to change on the fly. This statement also gives you more control over how errors are handled.
- FormulaValue --
- formulavariables( -- returns a list of variables used in a formula.
- Functions -- index of all functions available for use in Panorama formulas.
- grabdata( --
- Linking with Another Database -- multiple database files working together.
- makemergeformula( -- builds a formula from an “auto-wrap" style merge template.
- Non Decimal Numbers -- working with numbers in alternate (non-decimal) bases, including binary, octal and hexadecimal.
- Numbers -- Working with numeric values in a formula, and converting between numbers and text.
- Operators -- index of all operators available for use in Panorama formulas.
- Quotes -- text constants embedded into a formula
- Statements -- index of all statements available for use in Panorama procedures.
- SuperDates -- date and time combined into a single value.
- Tag Parsing --
- Text Formulas -- manipulating text with a formula (concatenation, extraction, rearranging, etc.)
- Time Arithmetic Formulas -- performing calculations on times, and converting between times and text.
- True/False Formulas -- logical boolean calculations.
- Using Fields in a Formula -- accessing database fields within a formula.
- Values -- the raw material that formulas work with -- numbers and text.
- Variables -- storing and retrieving individual items of data, not part of a database.

**History**

Version | Status | Notes |

10.2 | Updated | The database parameter can now be omitted if you want evaluate the formula based on the current database. |

10.0 | New | New in this version. |