Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Clear only one of several checkboxes

Featured Replies

  • 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.

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.

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.

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.

Hi Lee

because the value can be a part of another value.

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.

the value can be a part of another value.

So?


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

[ ¶ & "some item" & ¶ ; ¶ ] ;

[ "¶¶" ; "" ] 

)

That is beautiful comment!

  • 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!!

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.

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

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".

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.

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

Important Information

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.