Quick Start | Field Types | Scripting | Server Data Options | Advanced Functionality
If you need to perform a calculation, you can add a script to the field in which you want to display the result of the calculation.
Calculation Example 1: Performing a Simple Calculation
In the form shown below, the user can enter the price of an item and the quantity being purchased, and then calculate the total value of the items being purchased. The script to perform the calculation is in Field 4:
calculate:
answer = $2 * $3
A calculate: script is used in this case, so that every time the user updates the price or the quantity, the total value will be re-calculated as soon as the user leaves the updated field. The statement answer = $2 * $3 means that the answer to be placed in Field 4 is the multiplication of the value in Field 2 and the value in Field 3.
On the mobile device, the calculate: script triggers when any field on the form changes. The user has to leave a field for the change in that field to be registered.
When the user fills in the Unit Price and Quantity, he/she will need to tap in another field for the calculation to occur.
Calculation Example 2: Adding more than two values together
The scripting language in Pendragon Forms only supports binary math functions, that is, math functions with two numeric expressions. In order to add more than two values, you can break a calculation into smaller parts, using the result variable as temporary extra storage space for storing intermediate results of a larger calculation.
In the form below, in order to calculate total meal expenses for the day in field 5, the statement result = $2 + $3 stores the sum of Breakfast (field 2) and Lunch (field 3) in the result variable.
Calculation Example 3: Adding more than three values together
In this example, in order to calculate an average test score, the sum of test scores 1 through 5 must first be calculated.
This is the script in Field 7 to calculate Total points:
calculate:
result = $2 + $3
result = result + $4
result = result + $5
answer = result + $6
The “# of Tests Taken” field records how many tests have been taken by adding 1 for each non-zero score:
calculate:
result = 0
if $2<> null then
result = result + 1
endif
if $3 <> null then
result = result + 1
endif
if $4 <> null then
result = result + 1
endif
if $5 <> null then
result = result + 1
endif
if $6 <> null then
result = result + 1
endif
answer = result
The script that calculates the average has a check to see if the number of tests taken (Field 8) is zero. If it is zero, the return statement ends the script to prevent a divide by zero error.
If Field 8 is not zero, then the average of Total points/# of tests is calculated.
calculate:
if $8 = 0 then
return
else
answer = $7/$8
endif
Calculation Example 4: Dividing
Whenever you perform division in a form, you have to be careful to avoid division by zero errors. These errors can occur because calculate: scripts are triggered whenever an entry has been made in a field. If you have a form in which a number X is entered, followed by a number Y, and you want to calculate X/Y, the value of Y will be zero until the mobile user enters a value. As soon as a value is entered for X, the calculate script will run, and X/0 will cause the letters NaN (Not a Number) to be displayed on the device. There are simple scripting statements which can be used to prevent the calculation from occurring until field Y has a non-zero value.
Script to calculate A + B:
calculate:
answer = $1 + $2
Script to calculate A * B:
calculate:
answer = $1 + $2
Script to calculate A / B:
calculate:
if $2 = null then
return
else
answer = $1 / $2
endif
Script to calculate (A+B)/(C+D):
calculate:
if $8 = 0 then
return
else
answer = $5 / $8
endif
To calculate A / B in Field 7, a check is first done to see whether the divisor (number B in Field 2) is null (blank). If Field 2 is null, the return statement breaks out of the script so that the division is not performed. If Field 2 is not null, then the division of Field 1 by Field 2 proceeds.
Similarly, to calculate (A+B) / (C+D) in Field 9, a check is first carried out to see if the divisor (C+D) in Field 8 is zero.
Note: If you do not want to display too many decimal places, you can set the number of decimal places to display on the Data tab of each Numeric field in the Form Designer.
Calculation Example 5: Counter field
If you need to count the number of records in a form, there is a simple initialization script that can be used.
In addition to the script, it is necessary to make the counter field an Autodefault field on the Advanced Field Properties screen for that field.
initialize:
answer = answer + 1
Setting Field 1 to Autodefault means that when a new record is created, the value of the previous record is retained. The initialize script then adds 1 to increment the counter.
If you need to start the counter from 300, for example, simply enter the number 300 in the first record created. Subsequent records will be 301, 302, 303, etc.
Note that if the form is re-distributed to the device, or if the device is reset, the counter will be reset to 1.
Time fields, Date fields and Date & Time Fields can be used in calculations. Some notes:
Date Example 1: Today’s Date, and Time Elapsed
In this form, the first field defaults to today’s date, and other fields calculate the time elapsed between a starting and ending time.
The initialize: script in Field 1 only runs once when the record is created. The answer = now statement places the current date (or date & time) into Field 1.
initialize:
answer = now
calculate:
answer = $3 - $2
To calculate minutes, divide the seconds by 60.
calculate:
result = $3 - $2
answer = result / 60
To calculate hours, divide the seconds by 3600. (3600 seconds in one hour.)
calculate:
result = $3 - $2
answer = result / 3600
Date Example 2: Displaying Time Elapsed in Hours and Minutes
Since most people are used to expressing time elapsed in hours and minutes, you may want to display the results of date calculations in this way.
In Field 4, the time elapsed is calculated in seconds.
calculate:
answer = $3 - $2
The seconds are converted to hours by dividing by 3600, since there are 3600 seconds in an hour.
The integer statement takes just the whole number of hours, and this is placed in a field for storage.
calculate:
result = $4 / 3600
answer = integer result
The modulo (%) statement records a remainder, in this case the remainder of seconds after the whole number of hours is discarded.
The seconds are converted to minutes, and the whole number of minutes is stored in a field.
calculate:
result = $4 % 3600
result = result / 60
answer = integer result
To display the time elapsed as the phrase "X hrs and Y mins," the concatenate operator (&) is used to combine the whole number of hours, + the phrase "hrs and" + the whole number of minutes + the phrase "mins."
calculate:
result = $7 & " hrs and "
result = result & $8
answer = result & " mins"
Date Example 3: Calculating Ages
A useful calculation is to calculate a person’s age.
The statement result = now - $3 calcualtes the number of seconds from the date of birth to the present time and puts the answer in the result variable.
The result is divided by 86400 to convert seconds to days.
The number of days is divided by 365.25 to convert to years. (There are approximately 365.25 in a year, accounting for leap years.)
calculate:
result = now - $3
result = result / 86400
answer = result / 365.25
The result can be truncated to two decimal places by multiplying by 100 to preserve two decimal places of precision, then adding 0.5 to round up.
The integer statement takes a whole number and discards the excess decimal places; diving by 100 reverts to the correct level of precision.
calculate:
result = $4 * 100
result = result + 0.5
result = integer result
answer = result / 100
To round the present age to the age that the person will be this year, add 0.5 to round up, then the integer statement takes the whole number of years.
calculate:
result = $4 + 0.5
answer = integer result
Scripts can be used in fields to allow branching on a form. With branching, the mobile user’s response in one field determines which additional fields are displayed.
Branching Example 1: Branching from a Yes/No Checkbox field
In a Yes/No checkbox, there are three possible answers: Y for Yes, N for No, or null if the field is left blank. A branching script has to contain instructions for all possible answers. A blank response can be treated the same as answering No, if that is appropriate.
A select: event will run the script as the user makes a selection in the field. However, if the user leaves the field blank, a select: script will not run. An exitscreen: event runs when the user taps the Next button to move to the next screen, so an exitscreen: script will run even if the Yes/No field is left blank.
On the form below, Field 4 asks a Yes/No question. If the user answers Yes, then upon exiting the screen, the user will branch to field 5, which starts on the second screen of the form. If the user answers No, or leaves the Yes/No field blank, then he/she will skip all the questions on the second screen of the form, and will instead branch to field 9.
The exitscreen: event in field 4 runs when the user taps the Next button to move to the next screen. The if...then...else...endif statement sets up the branching conditions.
The statement means that if the answer in field 4 is Yes, the form will advance to display field 5:
if answer == Y then
goto 5
The else component of the if...then...else...endif statement covers what happens if the answer is not Yes, that is, if the answer is No or null.
else
goto 9
endif
This means that if the first condition (answer == Y) is not met, the form will branch to field 9.
On the device, selecting Yes in field 4 jumps the user to the next screen (field 5) when the Next button is tapped and the exitscreen: event runs.
Selecting No in field 4, or leaving field 4 blank causes the user to skip all the questions on the second screen, and jump ahead to field 9 on the third screen.
If the user jumps ahead to field 9, but then taps the Previous button, the screen with the skipped questions will be visible.
Branching Example 2: Branching from a Popup or Lookup List
If you want to branch based on a selection in a Popup or Lookup List, your script must account for every possible selection that the user can make from the list.
A select: event can be used, but the user has to make a selection for the script to run. If the user leaves the field blank, the script will never run. You can use an exitscreen: event if you want the script to run when the user leaves the current screen, whether or not a selection has been made.
A switch/case statement is used to specify what branching will occur for each of the possible options in the Popup or Lookup List.
In the form shown below, field 10 is a Popup List with a list of travel destinations. Depending on the user's selection, a question relating to that destination will be displayed, and the form will advance to that question. The extra questions are hidden in advance by checking the Hidden checkbox on the Visual tab of the Form Designer window, and the script will unhide the relevant question.
Here is the script in Field 10 in full:
exitscreen:
switch answer
case “Canada”
show 11
goto 11
case “United States”
show 12
goto 12
case “Europe”
show 13
goto 13
case “Asia”
show 14
goto 14
case “Africa”
show 15
goto 15
case anyvalue
msgbox “Please pick a destination”
endswitch
The exitscreen: event script has to contain instructions for each possible selection that the user can make in the Popup List.
exitscreen:
switch answer
This means that the value in the answer variable (that is, the value selected in the current field, will be compared to each of the options in the case statements.
case “Canada”
show 11
goto 11
This means that if the value in answer is Canada, field 11 will be displayed (show 11) and the form will branch to field 11 (goto 11). Similarly, each case statement details the actions that will be performed for each option in the Popup List.
At end of the script is this statement:
case anyvalue
msgbox “Please pick a destination”
Adding case anyvalue to the script will cover the actions to take if none of the case statement values match the value in the answer variable. For instance, if the user does make any selection from the list, the case anyvalue actions will be performed.
Adding case anyvalue to a switch/case statement is optional.
The last line of the script is:
endswitch
Every switch statement must end with the word endswitch.
Branching Example 3: Using a Goto statement with a Jump to Section field
A Jump to Section field contains some built-in branching capability that automatically allows you to jump to Section fields on your form. If you want the mobile user to branch back to the Jump to Section field after completing a section of a form, you can use a goto statement in the last field of that section.
In the following form, Field 7 is a Jump to Section field that allows the mobile user to jump to a section on the form. After the user has gone through the fields in a section, you may want the user to branch back to the Jump to Section field to be able to select another section.
When the mobile user exits the last field in a section, the form branches back to Field 7, the Jump to Section field. The Exit section is the only section which does not branch back to Field 7, so if the user selects the Exit option, he/she jumps to the final field(s) on the form and can end the record.
Scripts are used to carry out actions when the mobile user taps on a button in a Button field.
Button Script Example 1: Calculate Button
Calculate: scripts run whenever a field is updated. This is processor intensive, and may also cause calculations to be performed before the mobile user is ready. An alternative is to use a button to give the mobile user control of when the calculation is performed.
click:
$9 = $1 + $2
result = $3 + $4
result = result + $5
result = result + $6
$10 = result + $7
$11 = $9 - $10
In the form above, the last three fields on the form (Fields 9, 10 and 11) are not calculated until the user taps the Calculate button.
The advantage of using a button for calculations is that the user does not see intermediate results on screen before all the necessary data is input.
IMPORTANT: The disadvantage to using a button for calculations is that if the user changes a field, the calculated results do not change until the button is tapped again.
Button Script Example 2: Clone Button
In this example, the first few fields on a form will be the same for several records. To save the mobile user from re-entering the same data multiple times, a Button field is added to the form. Tapping the button clones the record, keeping the common data but erasing the fields that are different for each record.
The user fills out the first record then clicks the Button field.
The script in the Button field clones the first record, making a copy that keeps the value in the first two fields but nulls the value in the remaining fields on the form.
The script in the Button field of this form is:
click:
clone
$3 = null
$4 = null
$5 = null
The user can then fill out the remainder of the second record and click the Button field to create a third record.
The clone statement makes a new record that contains all the values from the previous record. The values in fields 1 and 2 (Date and Warehouse Location) are retained. The statements $3 = null, $4 = null and $5 = null cause fields 3, 4 and 5 to be set to null (empty/blank) so that the mobile user can enter new values in the new record. At any time the mobile user can manually change fields 1 and 2 as well, and subsequently cloned records will contain these changes.
MultiSelection fields are stored internally as a binary number, with each option in the MultiSelection List being represented by a bit position in the binary number.
A parent form and a subform are not really linked on the device - they only appear to be connected. Some scripts can be used to further enhance the appearance of a connection between the parent form and subform.
Adding across subform records, and placing the result on the parent form
In the parent form shown here, Field 10 is a Subform field that jumps to a subform used to enter items being ordered.
Field 12 is a Button field on the parent form, that the users taps to run the following script:
click:
subformsum "Order - Subform" 8
$13 = result
temp = $11 / 100
$14 = $13 * temp
$15 = $13 + $14
The statement subformsum “Order - Subform” 8 adds up the values in Field 8 of all the subform records that match the parent record. (In this example, Field 8 on the subform contains the total for one item being ordered.) “Order - Subform” is the name of the subform. The result of the calculation is placed in the result variable.
The statement $13 = result then places the calculated result in Field 13 of the parent form. The remainder of the script calculates the tax and the total including tax.
Note that if the mobile user enters more subform records after the Calc button has been tapped, he/she will need to tap the button again to update the parent form with the new total.
Using Scripts to do a Cascading Lookup
A Cascading Lookup enables you to have a user make a selection in Popup List or Lookup List field, and then display a list of items relevant to their selection in the earlier field.
A Reference Form is needed to do a Cascading Lookup.
Here is a sample Reference Form which will contain a list of rewards that a customer can earn. Field 1 is a Popup List for assigning a reward to a Gold, Silver or Bronze category.
Field 2 of the Reference form is a Text field for storing the name of a customer reward.
The Form Properties of the Reference Form have to be set to Keep Copy of Record on Device, and the default Additional Download Criteria of USERNAME = ##USERNAME## has to be erased to allow the records of the Reference Form to go to all devices.
Tip: To access the Form Properties screen, click the Properties icon next to the form name in the list of forms.
You can now create the form that will do the lookup to the Reference Form.
One field on this form should be a Popup List or a Lookup List that allows the user to select a category. In this example the categories in Field 3 are Gold, Silver or Bronze.
Another field on the form doing the lookup should be a Lookup List field, but instead of selecting a Lookup List to be displayed, select the name of the Reference Form. In this example the Reference Form is called Customer Rewards Ref1.
Important: The Field Name of the Lookup List should match the Field Name from the Reference Form that you want to copy data from.
After selecting the Reference Form to act as your Lookup List, click on the Script tab and enter the script that will make the lookup possible.
In this example, the script is:
click:
select “Customer Rewards Ref1” where field 1 is $3
The click: event script runs when the Lookup List field is tapped.
The select statement selects records from the Customer Rewards Ref1 form in which Field 1 of the Reference Form matches Field 3 of the current form. Field 3 of the current form is the reward category, so if the user selects a Gold reward in Field 3, when they tap in the Lookup List field they will see a list of Gold level rewards.
On the device, selecting an option in Field 3 determines which Lookup List will be displayed in field 6.
Selecting Gold in Field 3...
Displays all the records in the Reference form that have a Reward level of Gold.
Using Scripts to do a Double Cascading Lookup
A Double Cascading Lookup enables you to select records from a Reference Form based on two criteria instead of one as in a regular Cascading Lookup. For example, you might want to create a form in which you select a State, then select a City, and then see a list of customers in that City + State.
Tapping in the City field brings up a list of Cities in the selected State.
Tapping in the Company Name field displays a list of companies in the selected State and City. Selecting a company copies that company’s information into the form doing the lookup.
Three special fields and two Reference forms are required to do a Double Cascading Lookup.
One field is used to lookup a State. This field is just a regular Lookup List with a list of all the states.
The second field, City, does a single Cascading Lookup to look up the cities for the selected State. A Reference Form called “Cities and States” is used.
The third field, Company Name, does a Double Cascading Lookup to look up all the companies that match the two criteria of City and State. A Reference form called “Customer List” is used. The Reference Form needs a separate field for each criteria that you want to select.
This is the first Reference form, “Cities and States” that is used to look up a City once a State has been selected. Note that to copy fields into the form that is doing the lookup, the field names and field types have to match between the two forms. (A Text field can also copy into a Lookup List field.)
In the Forms List, click the Properties icon next to the first reference form, in this case the “Cities and States” form. On the Form Properties screen check to Keep Copy of Records on Device. Also delete the default Additional Download Criteria of Username = ##USERNAME## to allow records to go to all devices.
This is the second Reference form, called “Customer List”. The names of the fields on this form have to match the names of the fields on the form doing the lookup in order for data to copy from this reference form to the form doing the lookup.
As with the first Reference form, the Form Properties of the “Customer List” Reference form have to be set to Keep Copy of Records on Device, and the default Additional Download Criteria of Username = ##USERNAME## has to be deleted to allow all records to go to all mobile devices.
Now take a look at the form that is doing the Double Cascading Lookup. This form has the 3 fields needed to do the Double Cascading Lookup.
Field 1 is called State and is just a Lookup List field referencing a Lookup List called States with a list of states.
Field 2 is called City, and is a Lookup List field that instead of referencing a Lookup List, references the first Reference form which is called States and Cities.
Still in Field 2, on the Script tab is the script that selects all the cities that match the state from field 1.
The script is:
click:
select “States and Cities” where field 1 is $1
This script selects all the records from the “States and Cities” form in which Field 1 of that form matches $1 which is Field 1 (State) of the current form.
Field 3 of the form doing the lookup is the field that does the Double Cascading Lookup. It is a Lookup List field that references the “Customer List” Reference Form. Next look at the Script tab of this field.
This is the script that performs the Double Cascading Lookup:
click:
select “Customer List” where field 4 is $1
click:
select “Customer List” where field 3 is $2
The click: event runs when the user taps in the Company Name field to make a selection.
The first select statement selects records from the “Customer List” form in which Field 4 of “Customer List” (the State field) matches the State in $1, Field 1 of the current form.
The also statement combines two select statements. The second select statement acts on the records already selected by the first select statement. The second select statement selects records from the “Customer List” form that, having matched on State, also match field 3 of “Customer List” (the City field) to $2 – Field 2 of the current form, i.e. the City field.
A Custom Main Menu is a form that acts as a Main Menu and replaces the standard Pendragon Forms main menu screen that shows the list of form designs.
Features of a Custom Main Menu Form
A Custom Main Menu form is a Pendragon form with one special attribute:
Creating Custom Menu Options
To start, create a new form whose name begins with the word MENU in uppercase letters.
For each option on the Custom Main Menu form, create a Section field or a Button field. You can add a picture to a Section field.
Creating a Menu Option for Adding Records
In the MENU Form shown below, a Button field called Add a New Customer is created. A click: event script in the Button field allows users to add a new customer record.
The gotosubform "formname" new statement jumps the user to the specified form, and creates a new record for that form.
The following script is in field 1 of the form shown below (the 'Add a New Customer' menu option):
click:
gotosubform "Customer Info" new
This means that when the user taps in the Add a Customer button, the script will go to the form named "Customer Info" and create a new record.
After creating the Custom Main Menu form, remember to create all the other forms that the Custom Main Menu form refers to in each script.
Tip: In this example, the contents of the MENU form that the mobile user needs to access all fit on one screen. In this case, you can hide the End, Previous, and Next buttons so that the MENU form looks like a single screen.
The End and Previous buttons can be hidden via the Advanced Form Properties screen. To hide the Next button, an open: event script is written in Field 1 of the MENU form. An open: event is used as it will run every time the mobile user opens the MENU form. The script is:
open:
disable nextbutton
Creating a Menu Option to Review Existing Records
To create a menu option for reviewing existing records of a form:
The select all "formname" statement selects all the records of the specified form.
The review "formname" statement lets the user review the selected records for the specified form.
The following script is in Field 2 of the form shown below (the Select an Existing Customer menu option):
click:
select all "Customer Info"
review "Customer Info"
This means that when the user taps the Select an Existing Customer button, the script will select all the records in the form named "Customer Info" and display a Review screen. The user can tap on a record on the Review screen to go to that record.
Creating a Menu Option to Synchronize Pendragon Forms
If you are using a Custom Main Menu form, you will need to provide mobile users a way to synchronize their data.
In the example below, a Button field called Synchronize is created to allow users to synchronize the mobile device.
The script in the Button field to start synchronization is:
click:
synchronize
Creating a way to access the Pendragon Forms main menu
With a Custom Main Menu form, the mobile user has no way to access the standard Pendragon Forms main menu screen that shows the list of forms.
It is strongly recommended that you add to your Custom Main Menu form a way to access the Pendragon Forms main menu. In the event that there is a problem on the mobile device, you can direct the user to revert to the Pendragon Forms main menu to troubleshoot things like verifying how many form designs are on the device, or verifying what the form ID numbers are.
In the MENU Form example below, the End, Previous and Next buttons have been hidden from the user to make the MENU form appear to occupy a single screen. However, to access the Pendragon Forms main menu, the Next button first needs to be made visible so that the user can go to the second screen. A Button field named Admin is added to the form, and when the mobile user taps the Admin button, the Next button at the bottom of the screen is displayed. The script in the Admin button is:
click:
enable nextbutton
On the second screen of the MENU Form, a Text field is used to store a password, and a Button field is used to validate the password.
In the form shown below, the script in Field 7, the Button field, is as follows:
click:
if $6 == "Admin" then
$6 = null
endform
else
msgbox "That is not the correct password."
$6 = null
endif
If Field 6 (the password field) is equal to the phrase "Admin", the field is set to null to erase the password, and the endform statement ends the current form, which is the Custom Main Menu form. The user reverts to the standard Pendragon Forms main menu. If the password is not correct, a message is displayed.
If you have set up an administrative password to access the standard Pendragon Forms Main Menu, then entering the password and tapping the button to unlock the Custom Main Menu form will end the Custom Main Menu form and revert to the standard Pendragon Forms Main Menu that shows the list of forms on the mobile device.
Creating One Menu Option for Adding and Reviewing Records
Button fields and subforms can be used to create a custom menu option that allows the mobile user to jump to a form and then once in that form, have the choice of reviewing existing records or creating new records.
As always with Custom Main Menu forms, the form name must start with the word MENU in uppercase letters.
If a subform is being used, then the Custom Main Menu form will act as the parent form, and the rules governing parent forms and subforms will apply. In particular:
Using a Custom Main Menu form to Filter Records
If records of a form are pre-loaded onto the mobile device, a Custom Main Menu form can be set up as a way to filter the records. That is, the Custom Main Menu form acts as a place to enter selection criteria.
The review statement preserves any select statement filters that have been set by a script. The also statement is used to combine select statements.
In the form below, Field 1 stores a Zip code, and Field 2 stores a Maximum Price that a potential customer wants to pay for a house. Field 3 is a Button field with a click: event that lets the user view records based on the criteria set up in Fields 1 and 2. The script in Field 3 is:
click:
select "House Listing 1" where field 2 is $1
also
select "House Listing 1" where field 3 < $2
result = result & “Matches”
msgbox result
review "House Listing 1"
In this script, "House Listing 1" is the name of a form that contains one record per house on sale. Field 2 of "House Listing 1" is a Zip code, and Field 3 is the Asking Price of the seller.
The first select statement in the script selects all records in "House Listing 1" that match the zip code entered on the Custom Main Menu form. The also statement saves the currently selected records, and applies the next select statement on top of the existing selected records.
The review statement then displays the selected records, that is, all records within a certain Zip code and where the seller's asking price is less than the buyer's maximum price.
On the mobile device, when the user enters a Zip code and a maximum buyer's price and then taps the Section field to perform a search, a list of available houses that meet the criteria are displayed. The user can tap on a record to select it and view details.
Advanced Form Properties to Set on the Custom Main Menu
On the Sync tab, check the box to Keep a Copy of Records on Device. This causes there to be one record per user. Also keep the Additional Download Criteria of Username = ##USERNAME## so that the user’s MENU form record is sent to the mobile device.
If your MENU form is only 1 screen in size, then on the Behavior tab of the Forms Properties screen, you can check the boxes to hide the End button and the Back (Previous) button.
Depending on the application that you are trying to build, you may need more than one form on the handheld to implement your solution. Pendragon Forms supports the following:
Parent and Subform
A parent form and a subform (or child form) are used if you need to be able to create many child records for every parent record. Visiting the same customer or patient more than once, or taking several readings from the same piece of equipment may require you to create a parent form for the information that stays constant (e.g. the customer’s name or the equipment serial number), and create a subform for the information that changes (e.g. the details of a customer visit, or the equipment reading on a particular day).
Lookup to Another Form
If you want to maintain a reference list, such as inventory item numbers and prices, or employee names and addresses, and you want to select from the list and copy the data into a form, then you need to maintain two forms and do a Lookup to Another Form.
Example: Taking Orders on the Handheld
Creating an application to allow mobile users to take customer orders is an example that requires multiple forms.
To start, you will need a form for taking orders. However, since you cannot predict whether a given order will be for one item or for several items, you may want to split the order-taking form into two: a parent form for the customer information, and a subform for the line items being ordered. A new subform record is created for each item being ordered.
If you have a list of customers, you may want the user to pick from a list to select a customer. To achieve this, you can use a lookup to a customer form from the order-taking parent form.If you have a list of items for sale, you may want the mobile user to pick from the list to select an item being ordered. To achieve this, you can do a lookup from the subform to the list of items form.
The forms needed for this application and their relationship to each other is shown in the diagram below.
Advanced Scripting
There are some advanced scripting statements that are designed for working with multiple forms. Some of the advanced scripting statements include:
also
column number
delete
gotosubform formname { new | review | normal }
insert into formname
keycolumn number
lookup value within formname
select all formname
select matching formname
select formname where field field-number is expression
update field number = expression
Performing a Cascading Lookup to Another Form
A Cascading Lookup to Another Form allows you to specify a selection criteria in one field, and then display only the records in a reference form that match the selected criteria. Advanced scripting is required to do this.
Performing a Double Cascading Lookup
A double cascading lookup enables you to use two selection criteria to choose which records from a reference form are displayed when doing a lookup to another form.
(847) 816-9660
info@pendragonforms.com
Copyright © 2021 Pendragon Software Corporation. All Rights Reserved.