• Access textbox clearing out issue

    Author
    Topic
    #507315

    I have a form with a bunch of fields to do simple calculations where a user will enter in a number into a text box and then then another textbox will enter in a percent and the percentage of the first amount will return to the screen (so field one says 1000 and field 2 is 50% then it will return 500 to the screen). The fields that they enter into are unbound textboxes and I have a clear button on the screen that will wipe those amounts away by doing a text1.value = “”.
    However, I have a field that is doing a calculation where it is returning #Type! back to the screen when I open the form, where all the other fields are blank upon opening.
    I can’t get this field to be blank upon opening. Can someone help me to get this field to clear out when the clear button is pushed and to be blank when the form is opened?

    This is what is in the control source of this textbox:

    =IIf(IsNull([Text40]),””,100-(Val([Text40])+Val([Text42])+Val([Text44])))
    which will show 100 in the field as opposed to #Type!

    I have also tried this:
    =IIf([Text40]=””,””,100-(Val([Text40].[Value])+Val([Text42].[Value])+Val([Text44].[Value])))

    which returns the #Type!

    Any help is appreciated, thanks

    Viewing 0 reply threads
    Author
    Replies
    • #1582496

      The IIF statement evaluates both “sides”; that is, even if the condition is met, the other condition is also evaluated. So in your example, if Text40 is Null, then Val(text40) will fail. You might try Val(text40 + “”).

    Viewing 0 reply threads
    Reply To: Access textbox clearing out issue

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: