2 Replies Latest reply on Apr 9, 2011 3:29 AM by raybaudi

    Populate new Record entry with results from unsuccessful Find

    KennethCarl

      Title

      Populate new Record entry with results from unsuccessful Find

      Post

      Just as the default behavior for FileMaker Pro when a Find is successful is to show the first record in the Found set, I would like to have the behavior on unsuccessful Finds be to start making a new Record in Browse mode with the Find criteria pre-entered into the respective fields; I have tried to find solutions already but seem stuck on how to programmatically access the text entered into a field in Find mode (there is a function called Get(QuickFindText) but this is not associated with any field, and at any rate my users won't commonly be using Quick Find).

        • 1. Re: Populate new Record entry with results from unsuccessful Find
          philmodjunk

          Try using global fields for your find criteria. Then when the find comes up empty, create a new record and move the data from the global fields to fields in the new record.

          #using one global field just for example purposes
          Enter Find Mode []
          Set Field [YourTable::Name ; YourTable::GlobalNameField ]
          Set Error Capture [on] // suppresses "no records found" dialog so it doesn't interrupt the script.
          Perform Find[]
          If [ Get ( FoundCount ) = 0 ]
             New Record/Request
             Set field [Yourtable::Name ; YourTable::GlobalNameField]
          End IF

          Your user can enter a name into YourTable::GlobalNameField and then perform the above script. It will either find the record with this name or create a new one with that name.

          • 2. Re: Populate new Record entry with results from unsuccessful Find
            raybaudi

            "...but seem stuck on how to programmatically access the text entered into a field in Find mode"

            I think that a script like this could work:

            Set Error Capture [ On ]
            Enter Find Mode [ Pause ]
            Set Variable [ $values ; Value: YourTable::FirstField & ¶ & YourTable::SecondField ]
            Perform Find [ ]
            If [ Get ( LastError ) ]
            New Record/Request
            Set Field [ YourTable::FirstField ; GetValue ( $values ; 1 ) ]
            Set Field [ YourTable::SecondField ; GetValue ( $values ; 2 ) ]
            End If