Jump to content
Server Maintenance This Week. ×

Check box for value list- How do I validate so only one can be checked?


Joe_Schmo

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

Recommended Posts

I have a check box that displays two values from a value list. I want to make it impossible for the user to select both check boxes, and required to select one.

I don't know if this will cause a problem later, but in another table, I will be reusing the same value list as the source for a check box and will need the option to select both in that record. So the properties that restrict the user to select only one check box in the first table can't interfere with the ability to use that same value list on another table and be able to select both.

Should I make another table with just one field and two records instead of the value list and use a validation calculation instead? I'd rather stick with the value list if possible.

Link to comment
Share on other sites

Set the checkbox field to auto-enter (replace) with: RightValues ( Self ; 1 )

Be sure to uncheck 'do not replace existing value' so that it DOES replace existing values. It will then only allow one value in the field.

Sorry, added:

About the validation, are you still on vs. 10? If 11 then you can add a buffer of validation using trigger. In any case, field level validation is required if you want to guarantee success. Use 'member of value list'.

  • Like 1
Link to comment
Share on other sites

I didn't cover all of your questions, Joe!

Joe said, " in another table, I will be reusing the same value list as the source for a check box and will need the option to select both in that record. So the properties that restrict the user to select only one check box in the first table can't interfere with the ability to use that same value list on another table and be able to select both."

A value list is only a tool used for selecting values to insert into a field. You can attach the same value list to several fields if you wish. The values allowed into the field will ultimately be determined by the auto-enter (replace) and the validation which is attached to the field so each field will be treated differently, all using the same 'selector tool.'

So in the table on the field where you want multiple values allowed (choosing from a single value list) just remove the auto-enter ...

  • Like 1
Link to comment
Share on other sites

Set the checkbox field to auto-enter (replace) with: RightValues ( Self ; 1 )

Be sure to uncheck 'do not replace existing value' so that it DOES replace existing values. It will then only allow one value in the field.

Sorry, added:

About the validation, are you still on vs. 10? If 11 then you can add a buffer of validation using trigger. In any case, field level validation is required if you want to guarantee success. Use 'member of value list'.

I'm using v10 still, unfortunately. I'm having trouble setting up that replace calculation. What would the actual calculation be if the value list is named "IsoType", fields are "Mechanical" and "Electrical" and the check boxes are in "Isolation Points:Type"?

By the way, thanks for clearing up the value list thing. I understand what you're saying now, I just wasn't sure about how it worked before you explained it.

Thanks for the help!

Link to comment
Share on other sites

I'm having trouble setting up that replace calculation. What would the actual calculation be if the value list is named "IsoType", fields are "Mechanical" and "Electrical" and the check boxes are in "Isolation Points:Type"?

The calculation I gave you applies to a field and not a value list. File > Manage > Database > Fields tab and select Options for "Isolation Points:Type". At Auto-Enter tab, select 'Calculated value below' and type exactly the calculation I gave you (copy and paste it). The calc says:

Take myself (self) and filter (choose) only the right value in my field. In a list, values are separated by carriage return. The right value is my last value. And the right (last) value is the last item selected by the User since values are added to my field in order of selection (bottom value equals most recent). Since the auto-enter calc is disabled 'do not replace existing value if any', every time a selects or unselects a value, calc adjust itself (replace) and only keep most current entry.

So the properties that restrict the user to select only one check box in the first table can't interfere with the ability to use that same value list on another table and be able to select both.

You mention another table with same field? Value lists can be used from other tables so yes, you can use same value list. If you want all options available for selection on that field, don't add an auto-enter calculation to it. But I must mention this ... if you have another table with the same field name, do other fields in that other table also have some save field names as this table? Just curious.

ADDED; Oh and validation ... for the field you only want one value, if you use the auto-enter you won't need to validate that only one entry is allowed. If you did anyway, it would be: ValueCount ( Self ) = 1

  • Like 1
Link to comment
Share on other sites

Thank you both. I was able to get it working in this table as well as another location I needed a similar function.

LaRetta- Yes, there are a few fields that are in common to both tables. Basically, I have several tables to store all the info for personnel, isolation points, equipment, etc... and then there's the one table that combines info from all of the other tables for each instance of a maintenance item. That combination table is replacing a paper form we currently use for maintenance and all the other tables are just to provide dropdowns and check boxes to make filling out the form quicker.

I don't see where to mark this thread as soled. Most help forums have a way for the OP to close out a thread by marking it as "solved". Is that feature unavailable on FMForums?

Link to comment
Share on other sites

  • 2 years later...

Hi, and welcome to FMForums!

 

If you want a default value, use auto-enter DATA.  Just type your value (without quotes) into the auto-enter data box and you'll be set.  :-)

Link to comment
Share on other sites

I do not suggest that you abandon traditional interface conventions. Checkboxes are used to offer users the choice of none or many selections. Radio buttons are used to provide the choice of none or one selection.

 

And my suggestion is to consider a portal of related records rather than a checkbox array. It depends on reporting needs, but often that is the better way to structure the data.

Link to comment
Share on other sites

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