Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    Oct 2016
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Access textbox clearing out issue

    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

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts
    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 + "").
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •