Results 1 to 14 of 14
  1. #1
    sheckay is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    May 2022
    Posts
    85

    using a checkbox to remove calculated value in a text box on a form

    Hello. I have a form with some calculated values. They're working great. However, if I need to remove sales tax from the equation, I would need to be able to do that. So I thought I would create a yes/no check box on the form. Put it right next to the box that calculates the sales tax (TotalTax) and then put an IIF statement in the control source of the checkbox. Here's what I put in there: = IIf([TaxFreeCheck],"0","") AS TotalTax



    Yet it does not work. Why is that?

    Thank you in advance.

  2. #2
    sheckay is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    May 2022
    Posts
    85
    When I have the code in the spot that I mentioned I get the following error (when opening up the form that houses all of this): The record source '=IIF' specified on this form or report does not exist.
    Does this mean I just have to move the IIF expression to a different place? If so, where should I put it?

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    tax (and certianly a check box) is usually a number and your iif statement is trying to populate it with text and not a value. Not very clear as to waht name referes to what control so I presume your checkbox is called taxFreeCheck

    perhaps a better way would be formula in your totaltax control might be to calculate your totaltax

    =-somevalue*[taxFreeCheck]

  4. #4
    davegri's Avatar
    davegri is offline Excess Access
    Windows 11 Access 2021
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,741
    The code you added needs to be in the TotalTax textbox. BUT, you probably already have an = calculation there. The added code needs to take that into account.
    The new code logic is
    If taxFeeCheck is true then TotalTax = 0, otherwise TotalTax = whatever calculation you have now.

    Coded something like this:

    =IIF(TaxFreeCheck=True,0,ProductPrice * Taxrate)

  5. #5
    sheckay is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    May 2022
    Posts
    85
    Thank you for your reply. I'm not to populate the check box with text. I'm trying to override the value held in TotalTax (a text box on the form, which calculates the sales tax by taking in the subtotals and multiplying them by the sales tax rate. I am trying to overwrite that calculation with zero if the checkbox named taxfreecheck is checked.

  6. #6
    sheckay is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    May 2022
    Posts
    85
    Oh, OK. I was just trying something else. I created a text box that was going to be hidden. For that to run the code. But you're saying that I just put the existing calculation (more or less) into the false part of the check box's IIF statement?

  7. #7
    davegri's Avatar
    davegri is offline Excess Access
    Windows 11 Access 2021
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,741
    Quote Originally Posted by sheckay View Post
    Oh, OK. I was just trying something else. I created a text box that was going to be hidden. For that to run the code. But you're saying that I just put the existing calculation (more or less) into the false part of the check box's IIF statement?
    No, read my original reply again. The checkbox needs no code. The code goes in the TotalTax textbox.

  8. #8
    sheckay is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    May 2022
    Posts
    85
    Yeah, sorry I wasn't clear on that part. That's how I understood your reply. And that's what I'm currently trying. And it looks like Access is having trouble with the formula on the end. So I'm figuring out how to enter that part (which refers to the value of other text boxes.

  9. #9
    sheckay is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    May 2022
    Posts
    85
    Bravo...bravo...well done. Thank you.

  10. #10
    sheckay is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    May 2022
    Posts
    85
    Ooooh, I thought I was all done with that. But it looks like when that checkbox is unchecked the formula is populating the text box, not the calculation.

  11. #11
    sheckay is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    May 2022
    Posts
    85
    All set. I just had to change it to this: =IIf([TaxFreeCheck],"0",[extprice]*0.0765)

  12. #12
    davegri's Avatar
    davegri is offline Excess Access
    Windows 11 Access 2021
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,741
    OK, good to hear.

  13. #13
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    All set. I just had to change it to this: =IIf([TaxFreeCheck],"0",[extprice]*0.0765)
    I just hope you don't have to add that column - I'll leave you to figure out why

    As suggested in post#3 - @sheckay - please make sure you read all the posts, not just the last one. Otherwise you will get the reputation for wasting peoples time and they won't bother putting in an effort to help you

  14. #14
    sheckay is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    May 2022
    Posts
    85
    Thank you for the advise. I would not want such a reputation, nor would I want to actually waste anyone's time and/or effort. Thank you for your help.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Checkbox Click creates text in a text box
    By Akchayan in forum Forms
    Replies: 7
    Last Post: 11-10-2022, 03:43 AM
  2. Replies: 1
    Last Post: 05-22-2017, 05:59 AM
  3. Replies: 2
    Last Post: 03-25-2017, 10:04 PM
  4. Replies: 1
    Last Post: 11-26-2014, 02:30 PM
  5. Replies: 8
    Last Post: 09-08-2013, 12:34 AM

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
  •  
Other Forums: Microsoft Office Forums