James Gill Posted April 5, 2012 Posted April 5, 2012 I want to create a field that will display a calculated text result based upon several checkbox fields. Basically, I have 4 check boxes that can be selected and unselected independent of one another. I want to display a friendly result that will display the name of all check boxes that are checked. i.e. field1 = 1 field2 = 0 field3 = 1 field4 = 0 would return "Field1, Field3" and field1 = 1 field2 = 1 field3 = 1 field4 = 1 would return "Field1, Field2, Field3, Field4" What's the best way to do this?
imoree Posted April 6, 2012 Posted April 6, 2012 Something like this: substitute( GetFieldName ( CheckBox::field1 ) ; "::" ; "" )
databaser Posted April 6, 2012 Posted April 6, 2012 let(a=field1+field2+field3+field4; case(a=0;""; a=1 ; case(field1 ; "field1"; field2 ; "field2"; field3; "field3" ; field4 ; "field4"); let(b= if (field1; "field1, ") & if(field2; "field2, ") & if (field3; "field3, ") & if(field4 ; "field4, "); left(b ; length(-2) ) ) ) It's not clear what he's asking, but that would be an answer, if he means he has four fields where a value of 1 is either checked or unchecked. It's not the shortest way to write, but I think it's the way to write it that would calculate as quickly as possible.
bruceR Posted April 6, 2012 Posted April 6, 2012 Something like this: substitute( GetFieldName ( CheckBox::field1 ) ; "::" ; "" ) Have you actually tried that before submitting it? It doesn't work. And it doesn't address the problem across the set of fields in the original request.
imoree Posted April 6, 2012 Posted April 6, 2012 Have you actually tried that before submitting it? Yes i did actually! Works just fine for me if you have a Table named 'CheckBox' and a field names 'field1' respectively.
mr_vodka Posted April 6, 2012 Posted April 6, 2012 Yes i did actually! Works just fine for me if you have a Table named 'CheckBox' and a field names 'field1' respectively. Perhaps test again? Something like this: substitute( GetFieldName ( CheckBox::field1 ) ; "::" ; "" ) This would produce CheckBoxfield1
bcooney Posted April 6, 2012 Posted April 6, 2012 Why isn't the checkbox assigned to one field? Of course, because I'm Barbara, I will ask, "perhaps you need a join table?"
imoree Posted April 6, 2012 Posted April 6, 2012 Perhaps test again? This would produce CheckBoxfield1 TO have field1 or field 2 ,etc then this would do making sure fields were named properly such as field1, field2,etc,etc right( Substitute( GetFieldName ( CheckBox::field1) ; "::" ; "" ) ; valuecount( CheckBox::field1) +6 )
mr_vodka Posted April 6, 2012 Posted April 6, 2012 If all the fields are in the same table then you can use something like: Let ( tablename = LeftWords ( GetFieldName ( f1 ); 1); Substitute ( List ( Case ( f1; GetFieldName ( f1 ) ); Case ( f2; GetFieldName ( f2 ) ); Case ( f3; GetFieldName ( f3 ) ); Case ( f4; GetFieldName ( f4 ) ) ); tablename & "::"; "" ) )
imoree Posted April 6, 2012 Posted April 6, 2012 Nice one.. John.. Detailed , but nice. one. l love it when i post a mistake . i leave some stuff out of whatever i post, every expert is on my butt and all i am trying to do is help someone as best i know. ... Hilarious... :laugh:
bruceR Posted April 6, 2012 Posted April 6, 2012 It is not helpful to post untested, non-functioning, misleading responses.
bruceR Posted April 6, 2012 Posted April 6, 2012 TO have field1 or field 2 ,etc then this would do making sure fields were named properly such as field1, field2,etc,etc right( Substitute( GetFieldName ( CheckBox::field1) ; "::" ; "" ) ; valuecount( CheckBox::field1) +6 ) This is - basically - complete nonsense. Depending on the values in field1 1 this could produce any of the following: field1 (when field1 is completely empty) xfield1 oxfield1 boxfield1 kboxfield1 etc. Further, it is not dependent on whether field1 contains a "1" character. Further, it misleads from a more appropriate technical solution such as the join table proposed by Barbara.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now