1 Reply Latest reply on Dec 25, 2010 9:32 AM by RickWhitelaw

    Unable to catch error in simple Find script



      Unable to catch error in simple Find script


      I wanted to script a Find button for a solution I am writing. I found the following in the Help section of Filemaker pro 11

      Set Error Capture [ On ]
      Enter Find Mode [ Specified Find Requests: Find Records; Criteria: ClientDatabase::LastName: “Enter Last Name then press Enter Key” ] [ Restore; Pause ]
      Perform Find [ ]
      If [ Get ( LastError ) > 0 ]
      Show Custom Dialog [ Title: "No Records Found"; Message: "No records were found. Click OK to modify your request or click Cancel to return to Browse mode."; Buttons: “OK”, “Cancel” ]
      If [ Get ( LastMessageChoice ) = 1 ] 
      Modify Last Find
      Enter Browse Mode
      Show All Records 
      End If
      End If

      It works well except you can't capture the error in "Modify Last Find" script step if the user doesn't find any records or clicks on cancel. I tried another "Get (LastError)" after the "Modify Last Find", but it doesn't work.

      I also tried this after the last "End If"

      Go to Record/Request/Page [ First ] 
      If [ Get ( LastError ) = 101 ]
      Enter Browse Mode
      Show All Records 
      End If
      Sort Records [ Specified Sort Order: ClientDatabase::LastName; ascending ClientDatabase::FirstName; ascending ClientDatabase::DateFirstEntered; ascending ] [ Restore; No dialog ]
      Adjust Window [ Resize to Fit ] 
      Set Error Capture [ Off ]

      I thought if I captured for a found set of "0" that might work, but it didn't work.

      Any suggestions. I am sure there is an easy solution but I don't see it

      thanks for any help