Message in Null report field

  • Thread starter Thread starter scottyboyb
  • Start date Start date
S

scottyboyb

Good morning,

I have a text field (DonorOrganization) in a report (Unpaid Pledges). I
would like to have the field show and print n/a if the field is null and show
and print the field's data if it is not null. Here is what I have so far. It
stops at the line - Me!DonorOrganization = "n/a". So obviously I do not know
the correct syntax for the Else statement. Sorry to have such a simple
question. I should be able to figure this out, but not today.

Here is my code:
Private Sub Report_Open(Cancel As Integer)
If IsNull(Me!DonorOrganization) = True Then
Me!DonorOrganization = "n/a"
Else
Me!DonorOrganization
End If
End Sub

Thanks,
Scott
 
You don't need any VBA code to do this. Try setting the Control Source
property to:
=Nz([DonorOrganization],"n/a")
Make sure you change the name of the text box to "txtDO".

BTW: you can't dynamically set the value of a bound control in a report.
 
If the field contains null, you can use the format property to the control to
show N/A.

Set the format property of the control to
@;"N/A"

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 
I hadn't used the Format property like this for a text value. Good to know
it's possible.

--
Duane Hookom
Microsoft Access MVP


John Spencer said:
If the field contains null, you can use the format property to the control to
show N/A.

Set the format property of the control to
@;"N/A"

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

Duane said:
You don't need any VBA code to do this. Try setting the Control Source
property to:
=Nz([DonorOrganization],"n/a")
Make sure you change the name of the text box to "txtDO".

BTW: you can't dynamically set the value of a bound control in a report.
.
 
Sorry to take sop long to get back on this. Both ways worked! Yeah!

Thanks as always for the help. It is appreciated.

Best,
Scott

Duane Hookom said:
I hadn't used the Format property like this for a text value. Good to know
it's possible.

--
Duane Hookom
Microsoft Access MVP


John Spencer said:
If the field contains null, you can use the format property to the control to
show N/A.

Set the format property of the control to
@;"N/A"

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

Duane said:
You don't need any VBA code to do this. Try setting the Control Source
property to:
=Nz([DonorOrganization],"n/a")
Make sure you change the name of the text box to "txtDO".

BTW: you can't dynamically set the value of a bound control in a report.
.
 
Back
Top