April 21, 200223 yr I want to embed a find into a script, but the find may not always return a result (I.E. No records found). In my previous attempts, when nothing is found, a message pops up, and it leaves you with that. Since this will be running within a script, is there a way to do a "if no records found, skip" etc. Thanks -j
April 21, 200223 yr Set error capture to ON after the perform find step insert an if statement: Status(CurrentFoundCount) =0 Show message: "Sorry no records were found." show all records enter browse mode else insert rest of your script here... endif
April 21, 200223 yr At the top of your script, include 'Set Error Capture(On)'. This allows the script to trap not finding any records (or any other error). Immediately after the Peform Find step, insert 'Status(CurrentFoundCount)'. Either save it in a Setfield, or use it in an If test (it only survives one script step).
April 21, 200223 yr Set error capture to ON after the perform find step insert an if statement: Status(CurrentFoundCount) =0 Show message: "Sorry no records were found." show all records enter browse mode else insert rest of your script here... endif
April 21, 200223 yr Author quote: Originally posted by Ocean West: Set error capture to ON after the perform find step insert an if statement: Status(CurrentFoundCount) =0 Show message: "Sorry no records were found." show all records enter browse mode else insert rest of your script here... endif Just to make sure, in my case... Set error capture to ON Perform find if Status(CurrentFoundCount) =0 exit script (in my case) else continue performing script. I just ahve to make sure that nothing will popup and halt the script. It's going ot be running automatically w/out anyone attending it at certain intervals. I can't have anything stopping it.
April 21, 200223 yr Looks fine from down here. Just to confuse you, I always use: If Status(Current Error) = 401 to see if no records were found. There has been some discussion in the forums on which one of: Status(CurrentError) = 401 or Status(CurrentFoundCount) = 0 is best but I can't remember what the outcome was. Russ
April 22, 200223 yr quote: Originally posted by Russell Baker: Looks fine from down here. Just to confuse you, I always use: If Status(Current Error) = 401 to see if no records were found. There has been some discussion in the forums on which one of: Status(CurrentError) = 401 or Status(CurrentFoundCount) = 0 is best but I can't remember what the outcome was. Russ If FMI will change the "Status(CurrentError) = 401" to something else it will stop functioning. The second will work always.
April 22, 200223 yr I mad a global field called ErrorCode. This hold the code for the while script, so the code can be used well after other steps have run and even after other finds have occurred. code: Set Error Capture [on] Peform Find [] Set Field [ErrorCapture, Status(CurrentErrorCode)] Set Error Capture [off] If [ErrorCode <> 0] If [ErrorCode = 401] Show Message [No records found.] Find All records Exit Script Else Show Message [An error occurred.] End If End If [ April 21, 2002, 05:27 PM: Message edited by: Vaughan ]
Create an account or sign in to comment