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

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

Recommended Posts

  • Newbies
Posted

I have a database that has a field with 4 checkboxes. I am trying to write a script to clear the first checkbox without touching the others.

My latest attempt is:

Show All Records

Go to Record/Request/Page [First]

Loop

Set Field[Contact::Category; ""]

Go to Record/Request/Page [Next;Exit after last]

End Loop

Show All Records

I tried using a Get (FoundCount) = 0, but that put a "0" in all my records!!

I know somewhere I need to specify LeftValues(Contact_Category; 1) to indicate the first of the four fields. When I try to do this in a calculation it tells me there is no such field....

I am using FM Pro10.

Posted

Use this script on a copy of your DB, because this step can be dangerous !

Replace Field Contents [ No dialog ; YourTable::YourCheckBox ; FilterValues ( YourTable::YourCheckBox ; "value2¶value3¶value4" ) ]

Note that:

1) you have to create the string: "value2¶value3¶value4" using your real values.

2) to clear the first value for all the records you'll need to show all record, first.

Posted

Hi Daniele,

Why not just Substitute out the value with ""

Hi [color:orange]njentzsch,

You can do this using the Menu Replace, or a script using the Replace like this.

Replace Field Contents [ njentzsch::ckbx; Replace with calculation: Substitute ( njentzsch::ckbx ; "Yes" ; "" ) ]

I used the value of checkbox one of "Yes", you will need to use your true value of checkbox 1 instead.

HTH

Lee

[color:red]Note:

As Daniele mentioned. Test this on a copy of your file before doing this to the original, as you can not UNDO it.

Posted

The same step, but with this new calculation, will work better because:

1) it will reorder the values

2) it will skip the offending last ¶

3) there is no hard coded value

Replace Field Contents [ No dialog ; YourTable::YourCheckBox ;

Let([

values = RightValues ( ValueListItems ( Get ( FileName ) ; [color:red]"VL" ) ; 3 ) ;

text = FilterValues ( values ; YourTable::YourCheckBox )

];

Left ( text ; Length ( text ) - 1 )

)

]

where [color:red]"VL" is the name of your value list.

Posted

I am trying to write a script to clear the first checkbox without touching the others.

Let me rephrase that: you want to remove a certain item (if checked), and leave other CHECKED items in place. This is important, because checked items are stored in the order they were checked.

Posted

I do not see anything better than mine:

1) the "some item" is hard-coded

2) if "some item" is the lonely checked item, at the end we'll have a ¶ into the field instead of an empty field.

Posted

Hi Daniele,

I didn't see your second post, so obviously I didn't test it. I was comparing your first one, and mine, and they both left a carriage Return after the last entry, where as comment's did not.

I just tested your second suggestion, and I see that it works like comment's and removes the trailing return.

I did not intend to shun your reply, or insinuate anything by complimenting comments suggestion. In fact, between the three of us, we have educated more then the OP on how there is usually more then one way to accomplish the same thing in FileMaker.

Kudos to all of us. :laugh::yay::chili::tigger::giggle:

Lee

Posted

Ok, let's raise it up a notch:


Substitute ( "§¶" & CheckboxField & "¶§" ; 

[ ¶ & item & ¶ ; ¶ ] ;

[ "§¶" ; "" ] ; [ "¶§" ; "" ] ; [ "§" ; "" ]

) 

As for hard-coding, I don't see the big difference between spelling out the item and "item 1 out of 4 in ValueList XYZ".

Posted

But there is ( and you know ).

"item 1 out of 4 in ValueList XYZ" is dinamic; I could change it with another value and re-need the same script to clear the first value.

Also he just have a value list, so it isn't difficult to esplicity call it.

BTW: using FilterValues to obtain the last 3 values or changing the first value to empty ( with the corrected formula ) are, as Lee said, different ways to obtain the same thing.

Posted

I could change it with another value

So could I - and it doesn't have to be the first value in the list. Besides, this seems like a one-time adjustment, so I don't think it matters anyway.

different ways to obtain the same thing.

No argument there.

This topic is 5220 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.