October 9, 200124 yr I’m putting together a series of scripts to do finds for various criteria. The end result is a bunch of summaries and calculations that go into a mess of global fields for storage to be exported for a scorecard. Everything works just wonderfully unless there are no records found for a specific search, at that point that field will show the previous find results. My problem is that I need to have “zero” or a blank field or the previous number erased when no records are found.
October 9, 200124 yr Some of the other members may have a better solution for you, but you might want to (if you have IF functions) put an Else Omit Record step in there. When the script is done, it will show 0 records if none fit the criteria. Oh yeah. BobWeaver was kind enough to teach me this: If you are doing a loop, and want to omit records that don't match your criteria, you have to put it in like this: Else If [status(CurrentRecordNumber)=Status(CurrentFoundCount)] Omit Record Exit Loop If [1] Else Omit Record Hope this helps. Ken
October 9, 200124 yr Author Maybe I'm putting your suggestion in the wrong spot of the script (I put it just after the find and before it's puts in the global field) but, the results come out the same. I've tried it with and with out the loop with no difference.:
October 9, 200124 yr Yeah, it only pertains if you have a calculation in an If function. If you use this method, it could look something like this... Go to Record/Request/Page [First] Loop If ["Calculation"] Operations you want to happen Go to Record/Request/Page [Exit after last, next] Else If [status(CurrentRecordNumber)=Status(CurrentFoundCount)] Omit Record Exit Loop If [1] Else Omit Record End If End If End Loop It would be best if you could post an example script of what you have. Because if it has like a Perform Find with no If function, this wouldn't work. Perhaps some of the FM Pro gurus could step in here and help you further.
October 10, 200124 yr Doc, Are you using a version of FileMaker earlier than FM 5? FM 5 and later do in fact return an empty found set. You can set a condition in your script(s) such as If (Status(CurrentFoundSet) = 0, Set Field <x>, 0 Or did I misunderstand the problem?
October 10, 200124 yr Just a quick addition to what Kenneth2k1 said: Remember Filmaker’s ability to capture errors in scripts. Using the status CurrentError 401 you can also capture empty find results: This is an example straight out of the FM help file just as one example: Set Error Capture [On] Perform Find [Restore] Set Field ["global field", "Status (CurrentError)"] If ["global field <> 0"] If["global field = 401"] Create New Record/Request Else If["global field = 100"] Open ["another file"] End If End If End If I find the error capture function especially useful for testing scripts. In your case it would look something like this: Set Error Capture [On] Perform Find If [status CurrentError = 401] Set Field ["global field", 0] End If Just food for thought – Rigsby
October 10, 200124 yr Author Thanks Kenneth for your prompt reply yesterday. I have tried all of the suggested items and Moon wins the cigar! Moon, I do have FM5 and I don't show zero's in the summary fields (strange huh?) Thanks...you guys are the greatest! [ October 11, 2001: Message edited by: DocDeb ]
Create an account or sign in to comment