These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

If/Then Statement

possumgritz
Registered: Jan 20 2010
Posts: 5

I have a read only text box named "Age" with the following code.....

form1. # subform [0] . Age :: calculate - (FormCalc, client)
Age = Floor ( Sum ( DOBDays - ArrestDays )/365.25 )

This works fine for what I need but I would like it to work better. I have 2 fields that are date formatted named DOB and Arrest Day. I have 2 other fields named "DOBDays" and "Arrestdays" that do a date2Num function on the 2 date formatted fields.

When a user enters in info on one of the date fields the "Age" field throws in a negative age or a really high age. I realize that it is from the epoch date. I would like to do an IF/then statement that says something like............

if Age > 99 or Age < 1 then Age = "0"

Im a novice with this stuff, so I hope this makes sence. I appreciate any replies in advance.

Thanks!

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Why not check to see if there is data entered into the DOB or Arrest Day fields before performing the calculations for the number of days. For the DOBDays one could use:
if(HasValue(DOB) ) thenDate2Num(DOB.formattedValue, cFormatString)elsenullendif

So the DOBDays field only populates if data has been entered into the DOB field.

And a similar script for the Arrestdays.

George Kaiser

possumgritz
Registered: Jan 20 2010
Posts: 5
Thanks for the reply,
The DOBDays is already populated with the number calulated using the epoch date and todays date. It changes once you enter in a date. Here is the code for DOBDays.......

form1.#subform[0].DOBDays::calculate - (FormCalc, client)
form1.#subform[0].DOB.formattedValue
DOBDays = Floor((Date()-Date2Num(DOB.formattedValue,"MMDDYYYY")))
possumgritz
Registered: Jan 20 2010
Posts: 5
Ok, I dont think I understood what you said the first time but now I do. Your code works, however, I still get a number in the Age field when one of the fields DOB or Arrest Day has value. I would like for the Age field to work only when the DOB and Arrest Day both have value.