Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 5849 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies
Posted

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?

Posted

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.

Posted (edited)

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. :o

***************************************

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 by Guest
  • Newbies
Posted

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!

This topic is 5849 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.