You can't put a calculation in a Perform Find script step. That's not part of the calc engine. Variables do work though. So, load your SQL into a $variable and put that in the Perform Find.
Here is my development environment;
As you can see, the SQL works in producing a found set of 2 records.
However, when the layout loads, the layout acts as if the SQL code did not run.
It shows 3 records.
I put the code into a dialog both before and after the layout loads but it does
not seem to make a difference.... the labels layout always shows 3 records...
thanks for your thoughts....
Instead of all the screen shots...
I uploaded the app to dropbox.
The problem script is REPORTS / mnuSkillsLabels
So, the setup is:
Open the 'Skills' main window.
Select fromt he Reports dropdown: Category and Skill
In the Category and Skill window select Filter dropdown: Construction
Now run the mnuSkillsLabels script (in the Reports folder)
You're missing a couple fundamental pieces here.
Execute SQL is a script step that operates on SQL data sources over ODBC.
ExecuteSQL() is a function that runs a SQL-like query on a FileMaker database, returning a dataset.
The two are completely different and unrelated.
You're trying to create a found set of records.
Neither the script step nor the function will do that.
You could create your labels using ExecuteSQL() and a "virtual list" (search on TechNet for that term) which involves a new table, some variable manipulation, and a learning curve.
Or you can just drop the SQL idea, loop through your found set and drop the duplicates as you go.
Yes, the looping idea was considered. But, I was trying to see if FM or SQLExecute and ExecuteSQL could implement it's Dinstinct function. So, it looks like I am back to looping.
UPDATE: All I had to do was set a new field called DUP that held 1 if there was a duplicate then find all the records where DUP=0.
Now I just have to figure out the proper use and context for SQL... always something to learn.
Thanks for your help.
I'm pretty sure that you can solve your original problem by adding another TO of People behind Categories to find your distinct persons (as was suggested before), but if you want to use the function ExecuteSQL(), then don't confuse it with the script step Execute SQL  (note the blank.
EDIT: Didn't see DJ's post …
Message was edited by: erolst