August 8, 201015 yr Newbies 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.
August 8, 201015 yr 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.
August 8, 201015 yr 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.
August 8, 201015 yr 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.
August 9, 201015 yr 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.
August 9, 201015 yr the value can be a part of another value. So? Substitute ( "¶¶" & CheckboxField & "¶¶" ; [ ¶ & "some item" & ¶ ; ¶ ] ; [ "¶¶" ; "" ] )
August 9, 201015 yr Author Newbies Thanks to all who had suggestions. I will try (on a *copy* of my DB) and report back on success or (shudder) failure!!
August 9, 201015 yr 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.
August 9, 201015 yr 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. Lee
August 9, 201015 yr 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".
August 9, 201015 yr 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.
August 9, 201015 yr 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.
Create an account or sign in to comment