Display 0 in a textbox that obtains a null value from a subform

B

BZeyger

I am having a problem getting data to appear correctly.

I have a form which contains 3 subforms in the detail section. It is
designed to show the user data. It is not for editing. The subforms drive off
the same query but only display specific data.

Subform1 displays Art Hours
Subform2 displays Writing Hours
Subform3 displays QA Hours

Each subform contains the same fields and calculates the total number of
hours in each category. Such as the total number of Art hours, the total
number of Writing hours, and the total number of QA hours.

The main form retrieves the total amounts in text fields from the subforms:

txtTotalArtHours:
=([Subform1].[Form]![txtArtHoursTot])

txtTotalWritingHours:
=([Subform2].[Form]![txtWritingHoursTot])

txtTotalQAHours:
=([Subform3].[Form]![txtQAHoursTot])


This does pull info into the text fields as desired. However, if one of the
subforms does not have any information, I get a #Error in the text field.

How would I condition the text box to display “0†if there is not any value?
 
K

kc-mass

Surround your source with the NullZeroFunction like:
= NZ([Subform3].[Form]![txtQAHoursTot])
 
J

Jeff Boyce

Remember that "Null" in database terms means "nothing there".

This is NOT the same as 0 (a value) or a zero-length string (""), which
appears blank.

Are you handling the zls possibility, too?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
B

BZeyger

I would probaly never get a zero value. However, I would get instances where
no records would be received. I would like to account for not having any
results. If there aren't any results, I would like to have a zero value.




Jeff Boyce said:
Remember that "Null" in database terms means "nothing there".

This is NOT the same as 0 (a value) or a zero-length string (""), which
appears blank.

Are you handling the zls possibility, too?

Regards

Jeff Boyce
Microsoft Office/Access MVP

BZeyger said:
I am having a problem getting data to appear correctly.

I have a form which contains 3 subforms in the detail section. It is
designed to show the user data. It is not for editing. The subforms drive
off
the same query but only display specific data.

Subform1 displays Art Hours
Subform2 displays Writing Hours
Subform3 displays QA Hours

Each subform contains the same fields and calculates the total number of
hours in each category. Such as the total number of Art hours, the total
number of Writing hours, and the total number of QA hours.

The main form retrieves the total amounts in text fields from the
subforms:

txtTotalArtHours:
=([Subform1].[Form]![txtArtHoursTot])

txtTotalWritingHours:
=([Subform2].[Form]![txtWritingHoursTot])

txtTotalQAHours:
=([Subform3].[Form]![txtQAHoursTot])


This does pull info into the text fields as desired. However, if one of
the
subforms does not have any information, I get a #Error in the text field.

How would I condition the text box to display "0" if there is not any
value?
 
J

Jeff Boyce

As a recovering statistician, I feel obligated to point out the difference
between "I don't know" and "there aren't any". If you use a "0", how will
you know the difference?

Regards

Jeff Boyce
Microsoft Office/Access MVP


BZeyger said:
I would probaly never get a zero value. However, I would get instances
where
no records would be received. I would like to account for not having any
results. If there aren't any results, I would like to have a zero value.




Jeff Boyce said:
Remember that "Null" in database terms means "nothing there".

This is NOT the same as 0 (a value) or a zero-length string (""), which
appears blank.

Are you handling the zls possibility, too?

Regards

Jeff Boyce
Microsoft Office/Access MVP

BZeyger said:
I am having a problem getting data to appear correctly.

I have a form which contains 3 subforms in the detail section. It is
designed to show the user data. It is not for editing. The subforms
drive
off
the same query but only display specific data.

Subform1 displays Art Hours
Subform2 displays Writing Hours
Subform3 displays QA Hours

Each subform contains the same fields and calculates the total number
of
hours in each category. Such as the total number of Art hours, the
total
number of Writing hours, and the total number of QA hours.

The main form retrieves the total amounts in text fields from the
subforms:

txtTotalArtHours:
=([Subform1].[Form]![txtArtHoursTot])

txtTotalWritingHours:
=([Subform2].[Form]![txtWritingHoursTot])

txtTotalQAHours:
=([Subform3].[Form]![txtQAHoursTot])


This does pull info into the text fields as desired. However, if one of
the
subforms does not have any information, I get a #Error in the text
field.

How would I condition the text box to display "0" if there is not any
value?
 
B

BZeyger

My apologies. Your are right. I would never have a zero value in the hours.
The reason a user would input hours are if there are hours to input (hours >
0). I would only want a zero if there aren't any records retrieved from the
query.


Jeff Boyce said:
As a recovering statistician, I feel obligated to point out the difference
between "I don't know" and "there aren't any". If you use a "0", how will
you know the difference?

Regards

Jeff Boyce
Microsoft Office/Access MVP


BZeyger said:
I would probaly never get a zero value. However, I would get instances
where
no records would be received. I would like to account for not having any
results. If there aren't any results, I would like to have a zero value.




Jeff Boyce said:
Remember that "Null" in database terms means "nothing there".

This is NOT the same as 0 (a value) or a zero-length string (""), which
appears blank.

Are you handling the zls possibility, too?

Regards

Jeff Boyce
Microsoft Office/Access MVP

I am having a problem getting data to appear correctly.

I have a form which contains 3 subforms in the detail section. It is
designed to show the user data. It is not for editing. The subforms
drive
off
the same query but only display specific data.

Subform1 displays Art Hours
Subform2 displays Writing Hours
Subform3 displays QA Hours

Each subform contains the same fields and calculates the total number
of
hours in each category. Such as the total number of Art hours, the
total
number of Writing hours, and the total number of QA hours.

The main form retrieves the total amounts in text fields from the
subforms:

txtTotalArtHours:
=([Subform1].[Form]![txtArtHoursTot])

txtTotalWritingHours:
=([Subform2].[Form]![txtWritingHoursTot])

txtTotalQAHours:
=([Subform3].[Form]![txtQAHoursTot])


This does pull info into the text fields as desired. However, if one of
the
subforms does not have any information, I get a #Error in the text
field.

How would I condition the text box to display "0" if there is not any
value?
 
B

BZeyger

My apologies. Your are right. I would never have a zero value in the hours.
The reason a user would input hours are if there are hours to input (hours >
0). I would only want a zero if there aren't any records retrieved from the
query.


Jeff Boyce said:
As a recovering statistician, I feel obligated to point out the difference
between "I don't know" and "there aren't any". If you use a "0", how will
you know the difference?

Regards

Jeff Boyce
Microsoft Office/Access MVP


BZeyger said:
I would probaly never get a zero value. However, I would get instances
where
no records would be received. I would like to account for not having any
results. If there aren't any results, I would like to have a zero value.




Jeff Boyce said:
Remember that "Null" in database terms means "nothing there".

This is NOT the same as 0 (a value) or a zero-length string (""), which
appears blank.

Are you handling the zls possibility, too?

Regards

Jeff Boyce
Microsoft Office/Access MVP

I am having a problem getting data to appear correctly.

I have a form which contains 3 subforms in the detail section. It is
designed to show the user data. It is not for editing. The subforms
drive
off
the same query but only display specific data.

Subform1 displays Art Hours
Subform2 displays Writing Hours
Subform3 displays QA Hours

Each subform contains the same fields and calculates the total number
of
hours in each category. Such as the total number of Art hours, the
total
number of Writing hours, and the total number of QA hours.

The main form retrieves the total amounts in text fields from the
subforms:

txtTotalArtHours:
=([Subform1].[Form]![txtArtHoursTot])

txtTotalWritingHours:
=([Subform2].[Form]![txtWritingHoursTot])

txtTotalQAHours:
=([Subform3].[Form]![txtQAHoursTot])


This does pull info into the text fields as desired. However, if one of
the
subforms does not have any information, I get a #Error in the text
field.

How would I condition the text box to display "0" if there is not any
value?
 

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