13 Replies Latest reply on Mar 16, 2014 6:15 PM by RickWhitelaw

    Using "show all records" in a script

    MichaelShearer

      Title

      Using "show all records" in a script

      Post

           I have part of this script working but when I use "show all records" it doesn't do it.

           Here is what I'm trying to do:

           Find records that have X in a field. Go to field (what ever) and insert a 1. Show omitted records and put a 0 in field (what ever). Show all records.

           I have it putting the 1 and 0 in field (what ever) but it won't show all records.

           I can't locate an answer to this one.

           Need help

           Thx

           Mike

            

        • 1. Re: Using "show all records" in a script
          philmodjunk

               Parts of what you describe do not make sense. Other parts might by scripted in more than one way. I recommend posting your script.

               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: Using "show all records" in a script
            MichaelShearer

                 Phil you lucky devil, you are stuck with me again.

                 I have it uploaded. I was able to use the script you helped me with to get this to work.

            • 3. Re: Using "show all records" in a script
              philmodjunk

                   I almost never use a script step starting with the word "insert" except to insert files into container fields. Set Field is 99/100, the better option.

                   Your script only modifies at most two records and does nothing to Find the first record being modified

                   Can you explain in more detail what you are trying to do here?

              • 4. Re: Using "show all records" in a script
                MichaelShearer

                     Sure can,

                     I am putting the winner of a game into a field and then have FM find all the records with the winning team. Then go to another field and insert a 1 (for the correct pick). Then show all the records with the other team and put a 0 in the field. Then go to another field for game 2 and do the same thing.

                     Here are the fields:

                     Game #1 pick goes in field WPS#1. The winning team is placed in Win#1. FM finds all the matches and goes to G1 and puts a 1 in it. Then it shows all omitted members and places a 0 in G1. Then of course it will go to game 2 and do the same thing.

                     I thought I had a problem with it not being told to go to the first record.

                     This is the other script that runs after the one you already have.

                      

                      

                • 5. Re: Using "show all records" in a script
                  philmodjunk
                       

                            and then have FM find all the records with the winning team.

                       But no part of your script finds any records.

                  • 6. Re: Using "show all records" in a script
                    MichaelShearer

                         Your right but that is what it does in the script "Winners". Then it runs this script. I could make them one but this is just how I did it.

                         I can click on "Show all records " in the menu and it does it. I just don't understand why it doesn't when I put it in the script.

                         I have made the changes you suggested.

                    • 7. Re: Using "show all records" in a script
                      philmodjunk

                           Yes, but by only posting this small script you leave me in the dark about how you are trying to do this.

                           Assuming that your script correctly finds the record, the first part makes sense, but unless there are only two records in your table, this part isn't likely to produce correct results:

                           Show Omitted Only
                           Insert Text

                           Say you have 25 records in your table. The script that you did not post finds a record and this script changes the value of a field in the found record. Then show omitted only pulls up a found set of 24 record--all the other records in your table. And there is a very good chance that the above two script steps will thus modify data in the wrong record as you have a 1/24 chance of having the correct record as the current record.

                      • 8. Re: Using "show all records" in a script
                        MichaelShearer

                             I'm sorry Phil I thought I sent the first part. I'm attaching it to this.

                             There are 16 games so I will have to do this 16 times - not a problem once I get it to work.

                             Am I correct in assuming that if I told it to do another search without showing all records it would only search the found records?

                             I could skip putting 0's in the omitted records. That would save a few steps.

                             Thx

                             Mike

                        • 9. Re: Using "show all records" in a script
                          MichaelShearer

                               Now I'm finding that if FM only finds one record containing what the script is looking for, it will not "Show all records". If it finds two it works.

                          • 10. Re: Using "show all records" in a script
                            philmodjunk

                                 Show All record always works. But if you are trying to put the same value into more than one record after the Show Omitted Only, your script can't do that, it only modifies a single record. If you want to put a 0 into that field for all records in the found set, use Replace Field Contents.

                            • 11. Re: Using "show all records" in a script
                              MichaelShearer

                                   Ok Phil

                                   I have changed it to "replace contents" and dropped putting the 0's in the field. What do I use in place of "Show all records"?

                                   OR

                                   Do I need to show all records to have it search the entire db? I'm going to try it without using show all records and see if it works.

                              • 12. Re: Using "show all records" in a script
                                MichaelShearer

                                     Hey Phil

                                     I got it working. I'm attaching the script.

                                • 13. Re: Using "show all records" in a script
                                  RickWhitelaw

                                       I would put the Set Error Capture step at the beginning of your script. However, if you're not going to trap for errors it makes little difference other than you not ever knowing what errors were thrown.