Full Version: Default Value in Calculated Field
UtterAccess Forums > Microsoft® Access > Access Forms
I need to place a default value of £0.00 in a calculated unbound text box. The reason for this is that I have two sub datasheet forms on my form with two unbound text boxes that sum a total price from each subform. I then want to add the value in each textbox on the main form together in another unbound text box. This works fine, except if one of the totals is blank, which might happen as sometimes no entries are required.
herefore I need to make sure the calculation is performed even if one amount is £0. I have tried using the 'default value' property but this doesn’t seem to make nay difference.
Has anyone got an alternative solution I can use?
If you are putting the expression in the controlsource, then setting a default value won't work. What you CAN do, in that case, is use the NZ function to substitute a zero or other value for a null value in the calc.
If you are setting the value of the control in code, then you can test for nulls and set the value accordingly.
Use Nz function to convert Null value to 0:
On the Control Source of the control where you want the total to appear:
=Nz(Me.[NameOfControl], 0) + Nz(Me.[NameOfOtherControl], 0)
spot on chaps! many thanks!
You're welcome. Scott and I are glad we could help.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.