November 17, 200817 yr Newbies In a new database< i have 20 tables, none linked with any other at this point. I am cleaning them up to delete blank rows. I can do this by hand: go to layout "Single", say, click on find mode, enter an = in a field, click find, and delete records in the found set. However, a simple script to do this usually hits the error, "The operation could not be completed because the target is not part of a related table." I say usually because once in a while it works! Anyway, the script is simply: Go to layout[single"] Enter find mode[] Perform find[Restore] ... note below Delete all records[] note, the script for perform find has the specifiy find requests checked, which is where I have action as Find records amnd criteria Record =. Advice?
November 17, 200817 yr More than likely one of your perform finds with restored criteria is referencing a table of which your layout is not based on. Also you dont need the enter find mode step if you have a stored find. Furthermore, you really should have a check to see if it returns any found records mataching your criteria before you delete the records.
November 17, 200817 yr It appears you are looking to find blank records and then delete them. If there are multiple tables is there a common field name, e.g. "UserID? If not, how do you select the correct field to search? Your script would be more accurate if you used: Enter Find Mode() //uncheck Pause Set Field(FlagField; "=") Perform Find() Delete All Records //This makes me very antsy So I hope you have a backup before you do this? Conversely, you could place a Button with a script parameter on each layout and make sure you are referencing the right field for the right table layout. Set Variable($Parameter;Get(LayoutName) If ($Parameter = Table A) Go To Layout($Parameter) Enter Find Mode() Set Field (TableA::Flagfield; "=") Perform Find() Delete All Records //Again, make sure you have a back up EndIf Obviously, you need to create a separate IF statement for each layout. Usually, when I do this kind of clean up I run a loop and set a Flag like Set Field(Delete,"Yes") Then look at my data to just make sure it is what I want before I push the "KILL" button. But, that's me, I paranoid. *************************************** Good Point John. Set Variable($Parameter;Get(LayoutName) If ($Parameter = Table A) Go To Layout($Parameter) Enter Find Mode() Set Field (TableA::Flagfield; "=") Perform Find() If Get(lasterror = 0) Delete All Records //Again, make sure you have a back up Else Show Custom Dialog(No Records Found) Endif EndIf **************** Also, my scripts almost always need tweaking! Edited November 17, 200817 yr by Guest
November 19, 200817 yr Author Newbies Thanks! Using your suggestions, the script works now. Yes, it's dangerous, I wrecked probably a dozen copies of the database working on the script, so I definitely need to add some safeties!
Create an account or sign in to comment