Forum Discussion

HarrisonSmith's avatar
HarrisonSmith
Qrew Trainee
5 years ago

Prevent hundredths value from numeric field

Hello, 

I have a field (Hours), that should have entries that are whole numbers, or decimals in tenths of an hour (2.3). A lot of the time, users enter hundredths (2.25) instead. I don't want to automatically round, I just want to prevent the save from happening, and probably display a message like "Hours can only be entered in whole numbers or tenths of an hour". I thought using custom data rules might work, but I think I read somewhere that custom data rules aren't always reliable when users use grid edit, so I want to be sure whatever I do is 100% effective. Also, I need to prevent users from entering a value of 0; the # of hours should always be at least 0.1.​

If custom data rules would work, could someone provide a potential formula for this?

------------------------------
Harrison Smith
------------------------------
  • In fact Custom Data rules are perfect for your situation as they do work for Grid Edit or any other method like Importing from excel or API calls, and of course regular forms entry.

    The formula would be 



    IF(Round([Hours],0.1) < [Hours],"Hours can only be entered in whole numbers or tenths of an hour")

    It's possible that there could be some weird rounding errors so this might be safer.

    IF(Round([Hours],0.1) < Round([Hours],0.0001), "Hours can only be entered in whole numbers or tenths of an hour")





    ------------------------------
    Mark Shnier (YQC)
    Quick Base Solution Provider
    Your Quick Base Coach
    http://QuickBaseCoach.com
    mark.shnier@gmail.com
    ------------------------------
    • HarrisonSmith's avatar
      HarrisonSmith
      Qrew Trainee
      Hi, it appears neither of those formulas are working. The record is saving as usual when I try to enter a number with 2+ decimal places, and no warning message appears either.

      ------------------------------
      Harrison Smith
      ------------------------------
      • MarkShnier__You's avatar
        MarkShnier__You
        Icon for Qrew Legend rankQrew Legend
        I had a typo, try this

        IF(Round([Hours],0.1) <> Round([Hours],0.0001), "Hours can only be entered in whole numbers or tenths of an hour")

        also, did you check the checkbox to enable Custom Data Rules. The checkbox is above the formula box field.

        ------------------------------
        Mark Shnier (YQC)
        Quick Base Solution Provider
        Your Quick Base Coach
        http://QuickBaseCoach.com
        mark.shnier@gmail.com
        ------------------------------