Message in Null report field

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
 
D

Duane Hookom

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.
 
J

John Spencer

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
 
D

Duane Hookom

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.
.
 
S

scottyboyb

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.
.
 

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