How to Fix IIF Function Tax Calculations in Access Forms
Question details
The user needs to correctly calculate a tax amount based on whether a Yes/No checkbox is selected using the IIF function.
- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- Setting up a conditional expression in a form text box to calculate a 7% tax on an invoice total if the customer or invoice is marked as taxable.
- Observed behavior
- The attempted expression =IIF([CheckBox23]="Yes","[Invoice Total]*0.07","0") fails to calculate the tax correctly, either returning 0 or outputting literal text strings.
Verify the exact name of your checkbox control in the form's Property Sheet to ensure your expression references the correct field.
Correct the IIF Syntax and Boolean Logic
Fix the expression by properly evaluating the Yes/No field as a Boolean value and removing quotes from the mathematical operation.
A common mistake when referencing Yes/No fields in Access is treating them as text (like "Yes"). Yes/No fields actually store Boolean values, meaning their underlying data is represented as -1 for True (Yes) and 0 for False (No).
Additionally, placing quotation marks around your calculation turns it into a literal text string. To calculate the math, the numbers and field references must be written without surrounding quotes.
Right-click your form in the Access navigation pane and select 'Design View'.
Click on the text box where you want the calculated tax amount to be displayed, then press F4 to open the Property Sheet.
Navigate to the Data tab in the Property Sheet. In the Control Source property, enter the corrected formula: =IIF([CheckBox23]=True, [Invoice Total]*0.07, 0). Alternatively, you can use -1 instead of True: =IIF([CheckBox23]=-1, [Invoice Total]*0.07, 0).
Move the Calculation to a Query
Calculate the tax within an underlying query to keep your form's expressions simple and ensure consistent data across reports.
Manage Invoices and Calculations Effortlessly with WPS Spreadsheet
While Microsoft Access provides robust relational database management, designing functional forms and writing expressions can be complicated. If you only need to manage invoices, customer data, and conditional tax calculations, WPS Spreadsheet offers a much simpler solution. WPS Office is a highly compatible, free Microsoft Office alternative that allows you to easily execute logic with standard IF functions without worrying about complex Boolean data types.
- 1. Download WPS Office: Visit the official WPS website to download and install the free WPS Office suite for your operating system.
- 2. Open WPS Spreadsheet: Launch the application and select 'Spreadsheet' to start building or importing your invoice management system.
- 3. Apply IF Formulas: Use the standard IF function to calculate conditional values easily, such as =IF(A2="Yes", B2*0.07, 0), without needing complex Boolean adjustments.

Frequently Asked Questions
Why does my IIF calculation return a zero even when the Yes/No checkbox is checked?
This happens when you evaluate a Boolean Yes/No field against a text string like "Yes". In Access, a checked box actually equals True or -1. You must evaluate the field against True (e.g., [CheckBox]=True) for the formula to recognize the checked state.
Why is my IIF formula displaying the text of the formula instead of the actual calculation?
If you place quotation marks around your mathematical equation (e.g., "[Invoice Total]*0.07"), the database interprets it as literal text instead of a math operation. Removing the quotes will output the calculated numerical result.
How can I prevent previous invoice taxes from changing when tax rates update?
Instead of hardcoding the tax rate (like 0.07) into your form's IIF function, create a dedicated field to capture and store the specific tax percentage in the invoice table exactly when the invoice is created.




