Open manage | Database | fields from the File menu.
Find your text field
Double click it to open the Field Options Dialog.
Click the auto-enter tab in this dialog.
Click the "by calculation" option to open the specify calculation dialog.
Enter: TextFormatRemove ( Self )
And click OK. ("Self" is a special name you can use here so that the expression automatically refers to your field without needing to enter the actual field name in place of self. This makes it possible to set up utility expressions like this one and copy and paste them into multiple fields without having to edit them to add the specific field name.)
On the auto-enter tab, you'll find a check box for "do not replace existing value..." clear this check box. Since this calculation replaces the data entered by the user with the modified (format removed) data, it won't do anything unless this option is cleared.
That is great!! Works like a charm,
I have been searching for a solution like this and was glad I stumbled upon this post... only to find out it doesn't quite work for me :)
I am able to succesfully remove the text formatting of a text field using this calculation, however, the field I need to remove the format from is a lookup field. If I go to the Auto-Enter Options of the field and select "Calculated Value" it automatically removes the "Looked-up value."
Any way to change the format of a lookup field, as in, to bring over the data only and not any of the formatting?
Also, on a somewhat related note, is there a way to remove spacing from a lookup field? For example, if in Field A in Table 1 I have this text:
can this be "flushed" to the top in Field B of Table 2 (lookup) as:
I apologize if any of this has been answered in previous posts, though I couldn't find anything after thorough searching.
Thanks in advance to any who can help!
You could set a script trigger to apply on ObjectModify, or ObjectExit on that field. You could make the script set that field to itself, but with the step:
Set Field ( ThatField ; TextFormatRemove ( ThatField )
In the original table (the one the data is held in for the lookup) you could set an auto-enter calculation on that field, similar to TextFormatRemove, but with:
Filter ( ThatField ; "abcdefghijklmnopqrs...etc" )
and it will replace itself with only those characters in your filter list.
If you test your auto-enter on one record first you can then use the same function to do a 'Replace Field Contents' on your existing records.
I used your feedback to come up with a similar solution that I believe will work for now.
I didn't want to modify the original table and field, as special formatting is often used and required there... the tricky part was that even in the other table where the lookup field is used, special formatting is sometimes required as well, just in a different way and not as often. Having the script perform the TextFormatRemove calculation on ObjectModify/Entry/Exit/etc would eliminate the possibility of ever being able to format that field in the future.
The workaround was embedding the TextFormatRemove calculation into the script which initiates the creation of a new record and thus causes the lookup fields to be filled. Thus, when a new record is created and the data is pulled via lookup, the field in question has any prior formatting stripped, yet can be formatted later if needed. I also embedded a subsitute calculation for line breaks (found answers in other forum posts), as Trim/TrimAll would not work as needed. That also solved my other problem with all the extra spacing.
Hopefully some (or all) of this will be helpful to other users.
Thanks again for the help!