June 23, 200619 yr I need to write a close script to find all the blank records and delete them upon closing, I wrote a script to find the blanks in a field but when the field is already blank it trys to delete the entire data base is there a way to do this. Thanks in advance. Randy
June 23, 200619 yr When you say "already blank" I presume you mean it's empty in all records. Doesn't the script give you an error dialog? You need to trap for errors. E.g. Set error capture[On] Find[...] If[Get ( FoundCount ) = 0] . Exit script // or whatever End If or... If [Get (LastError) <> 0] or... If [Get (LastError) = 401]
June 23, 200619 yr Author Ok so I did this script Set Error capture [on] Enter Find mode Restore perform find if Get(FoundCount)=0 Close File[Current File] end if if Get(FoundCount)>0 Delete All Records[no dialog] Close File[Current File] end if It cycle into a loop on exit and deletes records. What is going wrong??? Thanks
June 23, 200619 yr A couple of points: 1) The loop happens because you invoke Close File in the script, which is itself invoked by closing the file. I'm not certain, but you probably don't need to Close File in the script since it's already the action taking place. 2) You can simplify the script to: Set Error Capture[On] Perform Find[Restore] /* Note: I don't like using the Restore option in finds, since I can never get them to work; I always end up coding my finds using Set Fields... */ If[Get(FoundCount)] Delete All Record[No Dialog] End If You don't need to test for FoundCount=0 since all you're doing is closing the file, which as I noted above, is the action taking place anyway. HTH, David
Create an account or sign in to comment