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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

unable to print 0 for blank database fields

Status
Not open for further replies.

cancer2006

Programmer
Aug 25, 2006
45
US
I am using CRW8.5 and Access 97
The database table looks like as follows:

Hours bcode
25.01 VAC
blank blank
36.6 PTO

I wan the output like as follows:
Hours bcode
25.01 VAC
0 0
36.6 PTO

Hours data type is number.

Following is my formula:

WhilePrintingRecords;
numberVar nOutput := 0;

// to detect for blank field
if {Hours} = 0 then nOutput := 0;

// The following formula prints the hours field which has numbers in it and also checking for other conditions. This is extra information that may help understand the problem.
If {Hours} <> 0 and {bcode} <> 'VAC'
then nOutput := {Hours};

I have also tried using the following:

WhilePrintingRecords;
numberVar nOutput := 0;

// to detect for blank field
if isnull({Hours}) then nOutput := 0;

If {Hours} <> 0 and {bcode} <> 'VAC'
then nOutput := {Hours};

nOutput;

Thanks for readig my problem and I apprecaite your help.
Thanks.
 
Your fields are probably Null and not really blank or 0. The easiest way to handle this is to go to Report Options on the file menu and turn on "Convert Database NULL Values to Default". If that doesn't work for you, there's a MUCH easier formula you can use:

If IsNull({Hours}) then 0 else {Hours}

-Dell

A computer only does what you actually told it to do - not what you thought you told it to do.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top