4 Replies Latest reply on Oct 18, 2010 1:34 PM by davidhead

    Simple script request for help

    KB-MT

      Title

      Simple script request for help

      Post

      My apologies from the start, but I am really new at FMPro11. I worked with a relational database program many years ago, but have forgotten a lot.

      I have created a simple database with a key field called OEM#. All I want to do is create a simple button with a script behind it that my coworker (a non-computer type) can press to search for a particular OEM number that he types into a search box. If the item is there, then the script should bring him to that record. If that OEM# is not already in the database - which will happen less and less as we build the database - then it should return a message that says it is not there and ask if he wants to enter it now. When he says yes, it should then bring him to a new, blank record screen.

      This sounds like it should be simple, and it probably is, but I am stuck. Can anyone advise please?  Thanks so much!

      KB

        • 1. Re: Simple script request for help
          davidhead

          You could try a script like this. It will prompt a search and capture the criteria used for later creating a new record if required when the search returns no records. Let me know if any of this needs further explanation.

          Go to Layout [ “Data” ]
          Enter Find Mode [ Pause ] 
          Set Variable [ $criteria; Value:Data::OEM# // capture the search criteria used ]
          Set Error Capture [ On ] 
          Perform Find [ ] 
          Set Error Capture [ Off ]
          If [ not Get ( FoundCount ) ]
          Show Custom Dialog [ Title: "Not Found"; Message: "The OEM number was not found.¶Do you want to create a new record for it now?"; Buttons: “No”, “Yes” ]
          If [ Get ( LastMessageChoice ) = 2 // Yes ]
          New Record/Request 
          Set Field [ Data::OEM#; $criteria ]
          Commit Records/Requests
          End If
          Show All Records
          Else
          #Display found record
          End If

          TS_Oz, FileMaker Inc.

          • 2. Re: Simple script request for help
            KB-MT

            OK, I was really excited at the start and followed along well... until I got to the very end. I got up until the place where you have

            #Display found record

            And I cannot find a way to input that statement. 

            I am obviously missing something here - can you help?

            Thanks!!

            KB

            • 3. Re: Simple script request for help
              LaRetta_1

              If the new record isn't created during the first portion, it means that - immediately after the Else - records were found.  # indicates a comment.  So it is simply saying there are no script steps to insert after the else because records will be found.  In fact, the Else isn't even required and the result would be the same ... you would end up with the record(s) you were searching for to begin with.

              • 4. Re: Simple script request for help
                davidhead

                LaRetta is correct in that the # line is a Comment line (see the Miscellaneous script steps at the end of the list). She is also correct in saying that the Else is not required. However, I usually put it in there as a matter of good explicit programming of intention - I intended for nothing else to happen if there was a record found.

                TS_Oz, FileMaker Inc.