default value with calculated field

L

Les Coover

MS Access 2000

On a form 3 fields: txtA, txtB, txtC

I use the control source property to create a calculated field
=[txtA]+[txtB]+[txtC] and name the calculated field SumIt.

Fine and dandy, everything works as long as I enter a NUMBER or ZERO in each
of the 3 fields.

But, I would like SumIt to add the fields together even when there is
nothing entered in one or two of the fields.

So my form will look better, so I won't have to look at a bunch of
zeros--just nice empty blank spaces when nothing is entered.

Well I tried making the default value in the table an empty string and a
null string but neither worked. Of cource I could make
the default value zero but this is where you came in--I want to get rid of
the zeros.

Anyone know how I can use my calculated field and not have to see zeros in
the fields where nothing is entered?

Thanks,

Les
 
L

Les Coover

Thanks, the answer was right in front of me on a help screen, I appreciate
your help
and please excuse my impatience.

Examples of performing arithmetic operations in forms, reports, and data
access pages

When you use an arithmetic operator (+, -, *, /) in an expression, and the
value of one of the controls in the expression is Null, the result of the
entire expression will be Null. On a form or report, if some records in one
of the controls that you used in the expression might have a Null value, you
can convert the Null value to zero by using the Nz function; for example:
=Nz([Subtotal])+Nz([Freight])

Les

Van T. Dinh said:
Try:

=Nz([txtA], 0) + Nz([txtB], 0) + Nz([txtC], 0)

--
HTH
Van T. Dinh
MVP (Access)



Les Coover said:
MS Access 2000

On a form 3 fields: txtA, txtB, txtC

I use the control source property to create a calculated field
=[txtA]+[txtB]+[txtC] and name the calculated field SumIt.

Fine and dandy, everything works as long as I enter a NUMBER or ZERO in each
of the 3 fields.

But, I would like SumIt to add the fields together even when there is
nothing entered in one or two of the fields.

So my form will look better, so I won't have to look at a bunch of
zeros--just nice empty blank spaces when nothing is entered.

Well I tried making the default value in the table an empty string and a
null string but neither worked. Of cource I could make
the default value zero but this is where you came in--I want to get rid of
the zeros.

Anyone know how I can use my calculated field and not have to see zeros in
the fields where nothing is entered?

Thanks,

Les
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top