How do I create a report that shows the word "None"

F

fredg

How do I create a report that shows the word "None" instead of being blank?

A report that shows the word "None"?
Perhaps you mean a control in the report that displays "None" when
it's value is null?

=IIf(IsNull([FieldName]),"None",[FieldName])

Make sure the name of this control is not the same as the name of any
control used in the control source expression.
 
M

Microwave

I need the word "None" to show in the "incident" field in the report when
there is no data / incidents.

fredg said:
How do I create a report that shows the word "None" instead of being blank?

A report that shows the word "None"?
Perhaps you mean a control in the report that displays "None" when
it's value is null?

=IIf(IsNull([FieldName]),"None",[FieldName])

Make sure the name of this control is not the same as the name of any
control used in the control source expression.
 
M

mrdavepet

I have similar question: I want the report to print "No data for this
setup" when Report/OnNoData is triggered.

How can I do that without putting IIF's in evey control.
 
R

Rob Parker

The usual way to do this is to use the report's NoData event to cancel the
report opening completely, and display a message box instead:

Private Sub Report_NoData(Cancel As Integer)
MsgBox "No data for this setup"
Cancel = True
End Sub

You will need to trap the error which arises from the Cancel in the code
which opens your report; this can be as simple as including:
On Error Resume Next
near the start of your code.

HTH.

The reply previously posted regarding using Iif statements will not work,
because it is not possible to test for anything being equal to Null.
Instead, you must test whether something is null. So, instead of:
IIF(YourField=null,"None,YourField)
you must use:
IIF(IsNull(YourField),"None",YourField)
Note: this also includes the closing delimiter for the string printed for
the true condition.

Note also that the comment that the code could be read as
"IIF(YourField=True,"Yes","No")" is incorrect and misleading.

HTH too,

Rob



I have similar question: I want the report to print "No data for this
setup" when Report/OnNoData is triggered.

How can I do that without putting IIF's in evey control.
 
M

mrdavepet

thanks

I have done what you suggested but I want to see ""No data for this
setup" printed on the report ie. A hardcopy of "No data for this
setup"
 
J

John Spencer

Add a label to the report header or to the Page header section with these
properties.

Name: lblNoData
Caption: There is no date for this report
Visible: No

In the form's No Data event add code like the following
Private Sub Report_NoData(Cancel As Integer)
Me.lblNoData.Visible = True
Me.Section(acDetail).Visible = False
'Add the next line if you have a group header
Me.Section(acGroupLevel1Footer).Visible = False
'Add the next line if you have a group footer
Me.Section(acGroupLevel1Header).Visible = False
'If you have additional sections to hide check out
'the Section property in help for guidance
End Sub



John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
 
M

mrdavepet

Worked great. Thank you


Add a label to the report header or to the Page header section with these
properties.

Name: lblNoData
Caption: There is no date for this report
Visible: No

In the form's No Data event add code like the following
Private Sub Report_NoData(Cancel As Integer)
    Me.lblNoData.Visible = True
    Me.Section(acDetail).Visible = False
'Add the next line if you have a group header
    Me.Section(acGroupLevel1Footer).Visible = False
'Add the next line if you have a group footer
    Me.Section(acGroupLevel1Header).Visible = False
'If you have additional sections to hide check out
'the Section property in help for guidance
End Sub

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County







- Show quoted text -
 

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