8 Replies Latest reply on Mar 12, 2014 8:37 AM by philmodjunk

    Complex find within find - second find not working

    bluorchid

      Title

      Complex find within find - second find not working

      Post

           Aloha,

           Am trying to determine if person is in the db.....either closed or open.  The same person could have several  records with two  dispositions:

           1) all closed OR

           2) one open

           3) not entered into the db

           My first find determines how many records a person has....

           1) no records - choice to open new record or cancel out of system

           2) 1 record - choice to review record or cancel out of system

           3) 2+ records - choice to review open,  review closed or cancel out of system.

           my first two work...but not the third.  the third is based on whether the records are "open" or "closed"

           I don't know how to send a copy of the script for  people to review....it seems a screen capture would be way to small to review.

           I have it saved as a pdf.

           thanks in advance

           regi

            

            

        • 1. Re: Complex find within find - second find not working
          philmodjunk

               To post a script to the forum:

                 
          1.           You can upload a screen shot of your script by using the Upload an Image controls located just below Post a New Answer.
          2.      
          3.           You can print a script to a PDF, open the PDF and then select and copy the script as text from the opened PDF to your clipboard for pasting here. (with this approach, you can get multiple script steps on the same line, please edit the pasted text by inserting some returns to separate those steps.)
          4.      
          5.           If You have FileMaker Advanced, you can generate a database design report and copy the script as text from there.
          6.      
          7.           If you paste a text form of the script, you can use the Script Pretty box in the Known Bugs List database to paste a version that is single spaced and indented for a more professional and easier to read format.
          • 2. Re: Complex find within find - second find not working
            bluorchid

                 ok...here's the script

            • 3. Re: Complex find within find - second find not working
              bluorchid
              /files/c09f072f89/find_script_page_2.jpg 780x639
              • 4. Re: Complex find within find - second find not working
                philmodjunk

                     Set Field [ Participant::Found count ] is missing the second parameter. If you are capturing the number of found records in a field, it should read:

                     Set Field [ Participant::Found count ; Get ( FoundCount ) ]

                     If [ Get ( LastError ) > 0 ]

                     Does not make sense in this context and should be removed. This part of your script is working because the step immediately above it is the incorrectly set up set field step and it is always generating an error message. Once you fix that set field step, this If step will never be true the way that it is written.

                     Enter Browse Mode, the next to last line in the first screen shot is harmless but redundant as the window is already in Browse mode at that point.

                     Your script then fails to return to find mode near the top of the second screen shot. Thus, set field is being executed in Browse mode and this step is thus modifying data in a field instead of specifying find criteria.

                     Instead of Perform Find[], use Constrain Found Set [] and your found set of open and closed records will be constrained to just open or just closed records.

                     The second round of scripting used to process the results of this last find contain the same incorrect set field step and incorrect use of Get ( LastError ) > 0.

                     Note if there is No error code returned, Get (LastError) returns zero. And get (LastError) only returns any error code returned by the script step performed immediately above it.

                     When Setting up Set Field, there are two Specify buttons that must be clicked. To get Set Field [Table::Field ; Expression], add set field to your script and click the first button (specify target field). Select Table::Field from the list of fields. Do not click the specify button next to the repetition box. Click OK to close this dialog box. Now click the lower specify button (calculated result) and create the expression to the right of the semicolon (;). Do not try to type in the semicolon.

                • 5. Re: Complex find within find - second find not working
                  bluorchid

                       thanks Phil...

                       will get to work on it....

                       much mahalo for your time

                       regi

                  • 6. Re: Complex find within find - second find not working
                    bluorchid

                         hey Phil...

                         got it running correctly...

                         have a quick question...

                         when you have entered find mode....

                         what events cause you to exit find mode?

                         performing a find?

                    • 7. Re: Complex find within find - second find not working
                      philmodjunk

                           Either Perform Find, it's related steps: Constrain Found Set and Extend Found Set or one of the steps that explicitly enter a different mode such as Enter Browse mode.

                      • 8. Re: Complex find within find - second find not working
                        philmodjunk

                             Note: When working with complex scripts, FileMaker Advanced is Invaluable as you can open the script debugger and data viewer, then perform your script and be able to step through the script watching your layout change, variables and fields update all one step of your script at a time. This can save you hours of puzzling out why a long script like this doesn't produce the results that you expected.