Jump to content

Show zero or blank when no records are found


This topic is 7317 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.:

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 ]

Link to comment
Share on other sites

This topic is 7317 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.