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

Hiding fields when they are null 2

Status
Not open for further replies.

Stevehewitt

IS-IT--Management
Jun 7, 2001
2,075
GB
Hello!

I have a report that comes out with details of a purchase. On the form used to create the report you can enter in 10 records (purchases). You have to enter quantity, description, cost etc.

The problem is that some of these fields are numbers, so they automatically have a default value of "0". So if a users purchased 4 items, the report will not only show those 4, but also all records as they have "0" as a number.

Any ideas on how to remove this problem?

Thanks,

Steve Hewitt
 
If you want to skip printing a record if a field's value is zero (for example: quantity), then put code like this in the On Format event of your report's detail section:
Code:
If Me.Quantity = 0 Then
   Cancel = True
End If
Also, just because a field is numeric, it doesn't have to have a default value defined. That property can be empty if you want.
 
Thanks, a star for that! :)

One other thing related to it. Now that the price/qry have all been canceled - the total no longer adds up. (sorta important for a purchase order!)

The sum was subtotal1+subtotal2+ etc.

Any ideas?

Steve Hewitt
 
I thought those records contained zero values that would not affect any calculations. If the record should still appear because some fields within must be summed then you should either delete the default value for these fields so the zero won't appear, or put code like this in the report's detail section for each text box you want to be invisible:
Code:
If Me.Quantity = 0 Then
   Me.Quantity.Visible = False
Else
   Me.Quantity.Visible = True
End If
 
Thanks,

I've been getting a bit lazy recently with Tek Tips. I'll give myself a slap on the wrist! :)

I've used conditional formatting instead. If the value equal 0 then its white.

Cheers,

Steve Hewitt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top