4 Replies Latest reply on Feb 8, 2009 11:19 AM by miw

    Forcing a numeric input



      Forcing a numeric input


      I have a field that is defined as "numeric only."  However, when I am in input mode on my layout and type text in the field, I get a Filemaker default message that asks if I want to keep the non-numeric value.  If I say yes, it records the non-numeric value in the record - totally defeating the "numeric only" requirement.  Any suggestions for a script I can use to avoid this default message so that a text input will not be accepted at all?  Ideally, this default message from FileMaker would not even appear as an option and I can write my own dialog screen demanding a numeric value only and reverting back to the field for a proper numeric input.  Since I have many such numeric only inputs, such script will be a test to deal with the current field subjected to modification (in other words I wouldn't want a script that demands I name a specific field each time; otherwise I would need to have multiple scripts specific to each field running the same test).

        • 1. Re: Forcing a numeric input



          Thank you for your post.


          The easiest way is to set the Auto-enter options and have it filter out any non-numeric characters.  That is, pull down the File menu and select "Manage -> Database..."  Click on the Fields tab and select the field you want a numeric value.  Click on Options, and under "Auto-Enter", put a check mark in "Calculated value".  In the next screen, enter the formula:


          Filter ( <numeric field in question> ; "0123456789" )


          Click OK, and that should return you to the Auto-Enter options.  Be sure to uncheck the option just below that "Do not replace existing value of field (if any)".


          Click OK a couple of times, and now if you enter:




          ... and tab out of the field, the text is filtered out and leaves you with 5437.


          You didn't mention which version of FileMaker Pro you are using, but if you are using FileMaker Pro 10, you can set up a script trigger so that each keystroke is captured and evaluated.  If you need help with that, let me know.



          FileMaker, Inc. 

          • 2. Re: Forcing a numeric input

            Hi MIW


            you have to check 1 box in the validation options for that field:


            1) numeric only


            AND to uncheck 1 box:


            2) Allow user to override during data entry


            If you wish your own error message, check the box:


            3) Display custom message if validation fais



            you forgot that a numeric value can be negative and not integer.


            Filter ( <numeric field in question> ; "-.,0123456789" )

            • 3. Re: Forcing a numeric input

              You could also set the user's Access Privileges to 'Allow warning dialogue override = 'No', and then they will get the warning that says the data entry is invalid (so at least they know why it has been changed, or dis-allowed) but will not have any 'Yes' option to accept.




              Edited: sorry, maybe my memory serves me wrong and I am only making the same point as raybaudi:


              "AND to uncheck 1 box:


              2) Allow user to override during data entry"


              • 4. Re: Forcing a numeric input

                TSGal, raybaudi and sorbuster:  all great and varied solutions to fix my problem - I learned a few new things from each of your recommendations.


                Many thanks