4 Replies Latest reply on Aug 16, 2011 10:25 AM by huge826

    Fixed length field



      Fixed length field


      I am trying to create a fixed length field. It should not matter if the original field has 2 characters or 100 it should remain 16 characters. Is there a way to do this in FM Pro Advanced?

        • 1. Re: Fixed length field

          In FileMaker Pro or Advanced, you can open Manage | Database | Fields, and use field options to set a maximum number of characters on the validation tab. That still allows the user to enter more than the specified maximum, but an error message will pop up requiring them to return and fix the problem or to revert.

          You can also use the OnObjectKeystroke script trigger to perform a script to count the number of characters in the field one keystroke at a time. Exit Script [False] can be used to ignore all additional characters once the max character length is reached. If you use this script, allow at least a tab, return or enter key to not be ignored so that your user can use that key or keys to exit the field after the maximum number of characters have been entered. You can also allow arrow and delete keys to still work to keep the field editable once the max length is reached. (See Code and Char functions in Help for the codes for these special characters.)

          • 2. Re: Fixed length field

            Thank You for your response. A little added info, There is no data entery I am importing the data from another table where I want to have a field with a fixed length to import the data to. This would allow me to send any length to this field and it would remain at 16 characters. Does the max number in the validation tab do this or if there are only 10 characters in the field does it reduce the size from 16 to 10?

            • 3. Re: Fixed length field

              Unfortunately, it will either ignore the setting if validation is set to "only during data entry" or it will reject the entire record during import (Skip it) if you select "Always".

              You'll need to either use replace field contents after import or you can import the value into a global field and define an auto-enter calculation that uses the same calculation to enter the specified number of characters into the data field.

              Left ( YourField ; 10 )  returns the left 10 characters.
              Right ( YourField ; 10 ) Returns the right 10 characters.

              • 4. Re: Fixed length field

                Thanx for your help, I think I will have to get creative. I did see a function that actually counts the characters in the field and I will use that to pad the fields with less than 16 Characters. Anything over 16 is no prob using the Left (Text;12) function. All I will have to do is find the fields less than 16.

                Thanx again.