AnsweredAssumed Answered

Set Field/Variable to "0", when Perform Find results = 0

Question asked by Derrenger on Aug 24, 2010
Latest reply on Aug 24, 2010 by LaRetta_1


Set Field/Variable to "0", when Perform Find results = 0


First time posting in Forum, and have been able to answer all prior questions by researching these extensive boards, but this time I'm stuck. I am using FMP 11.

I have a table (Layout#1 - which only has one record) that updates itself based on records in a related table (Layout#2 - which has several hundred records) using a script.

I can get it to go to Layout#2, find records based on a given parameter, set the variable, go back to Layout#1, and set field... but this only works when there are actually records present based on the find.

If no records are found, I just get a blank field, and what I really want is a "0". I've tired using If [Get (FoundCount) = 0, .... but that's not fixing the problem.

I am using the following script, but am obviously missing something:

Go to Layout (Layout #2)

Show All Records

Perform Find

If [Get (FoundCount) = 0]

   Set Field [Layout#1::Field#1; 0]

Else If [Get (FoundCount) > 0]

   Set Variable [$total; Value:GetAsNumber (Layout #2::Field#2)]

   Go to Layout [Layout#1]

   Set Field [Layout#1::Field#1; $total]

End If

Any help or guidance would be greatly appreciated... and thank you in advance for your time and assistance.