Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Null problems in a form...Totaling problems

Status
Not open for further replies.

DJKAOS

Technical User
Jun 30, 2000
101
US
I'm having trouble with this...
I have some fields say
FIELD1
FIELD2
FIELD3
FIELD4
FIELD5
TOTAL

lets say the user types values into Field2, Field3, Field4
but leaves field1 and field5 blank...

WHen I calculate the total I want it to work without having to type 0's into the blank fields..

I'm trying to do it in VB code but it doesn't seem to work..
I have it something like this

if(Field1 <> Null)then
TOTAL = TOTAL + Field1
else
'ITs null dont add it to total
endif

Why doesn't that work? it never runs the code.

 
look at the nz function

=nz(field1)+nz(filed2)+nz(filed3)+nz(filed4)+nz(filed5)
 

Braindead’s answer has told you how to compute the total, but if your code does not execute, you obviously have another problem which is easily resolved. I am sure you are complying with the rule of whatever can be computed is never stored anywhere, you are trying to compute the total in a vb subroutine. Don’t bother. Put it as the control source of TOTAL. So that in the properties for total, the control source will be:

=nz(field1) + nz(field2)+nz(field3) +nz(field4) + nz(field5)
Robert Berman
Data Base consultant
Vulcan Software Services
thornmastr@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top