locked
Decimal field on a screen forces me to use 0 to remove the entry. RRS feed

  • Question

  • I have several decimal fields defined in SQL as decimal (5, 1).  I am using custom formatting in the entity designer as ####.#    The fields display perfectly but I have a problem when it comes to removing an existing entry.

    I would like to have the users simply hit the Delete key while in the field to remove the entry but the system throws an error  about an invalid value.  The only way to remove the entry is to change it to zero which will then display as "blank" due to formatting.  Is there any way for me to allow the user to use the delete key instead of having to change the value to zero?

    Thanks.

       
    Saturday, February 22, 2014 5:28 PM

Answers

  • It sounds like the decimal type in SQL does not allow nulls.  A non-nullable decimal is a value type and cannot be set to null.  So you will either need to set it zero in code, or change the sql type to allow nulls.  Then you can use .HasValue or .GetValueOrDefault() in your code or set it to null (or nothing in VB).
    • Proposed as answer by Hessc Saturday, February 22, 2014 8:03 PM
    • Edited by Hessc Saturday, February 22, 2014 8:04 PM
    • Marked as answer by Angie Xu Monday, March 3, 2014 2:11 AM
    Saturday, February 22, 2014 8:03 PM