Creative Wisdom ยท FileMaker Pro tipsArchive

Setting up a counter

Chong Ho (Alex) Yu, Ph.D., MCSE, CNE, CCNA (2001)

Problem

I am setting up a conference registration DB. I want to give a group discount to any group who has ten or more members. By using a token I am able to assign the same group ID to every member of the same group. But how can I set up a counter to count the number of members?

Solution

  • You need at least two pages to increment the counter. Create a form for the first member and another form for additional member(s). The two forms are identical except the counter.
  • In the database create a text name named "counter". In the first form create a hidden submission to "counter" and put the initial value of the counter into a token:

                <INPUT TYPE=hidden NAME="counter" VALUE="1">
                <INPUT TYPE="hidden" NAME="-token" VALUE="[FMP-Field:counter]">
  • You can set the "-format" field" in the first page pointing to the second page. In the second form create another hidden submission to "counter." Please notice that the input to the counter is the value of the previous counter value plus one. However, the new number just appends to the previous number. In other words, the new value will be "11" rather than "2".

                <INPUT TYPE=hidden NAME="counter" VALUE="[FMP-Field:counter]">
                <INPUT TYPE="hidden" NAME="-token" VALUE="[FMP-Field: counter]">
  • You should set "-format" field" in the second page pointing to the itself. If the same form is used to submit information of ten members, the counter will increment ten times.
  • In the database create a calculation field named "counter_all". The calculation function is length(counter). If the first form is submitted once and the second form is submitted ten times, "counter" will contain the text string "11111111111", and "counter_all" will be "11".