IF Statement in detail line of report

B

Brushcut1

There are two fields in the report that I need to
selectively not print in the Report.

They are: [Phone Number] and [E-mail Address]
There are also two additional 1 character fields named:
[Publish Phone N] and [Publish Email] containing either Y
or N.

In the Report Design view, under detail, when the field
is defined as "Phone Number" it prints all the phone
numbers in the report. However, I have been trying to
replace "Phone Number" with an "IF" expression.

I have coded it as follows but cannot get it to work:
IIf([Publish Phone N]="Y",[Phone Number]," ")

Should the If be "If" or "IIf"?

I'm new to using Access.

Thanks, Dick
 
F

fredg

There are two fields in the report that I need to
selectively not print in the Report.

They are: [Phone Number] and [E-mail Address]
There are also two additional 1 character fields named:
[Publish Phone N] and [Publish Email] containing either Y
or N.

In the Report Design view, under detail, when the field
is defined as "Phone Number" it prints all the phone
numbers in the report. However, I have been trying to
replace "Phone Number" with an "IF" expression.

I have coded it as follows but cannot get it to work:
IIf([Publish Phone N]="Y",[Phone Number]," ")

Should the If be "If" or "IIf"?

I'm new to using Access.

Thanks, Dick

'cannot get it to work' doesn't give us much information.

= IIf([Publish Phone N]="Y",[Phone Number],"")

should work. Make sure the name of the control is not the same as the
name of one of the fields used in the expression.

If that doesn't help, perhaps you should let us know what it does do.
 
B

Brushcut1

Fred, thanks for your reply. I keyed the expression in
again with the =IIF and no space between the "" in
the "if false" parameter. Now it works. I was getting
syntax errors and couldn't resolve them. I now have both
conditional fields working correctly.
Thanks again,
Dick
-----Original Message-----
There are two fields in the report that I need to
selectively not print in the Report.

They are: [Phone Number] and [E-mail Address]
There are also two additional 1 character fields named:
[Publish Phone N] and [Publish Email] containing either Y
or N.

In the Report Design view, under detail, when the field
is defined as "Phone Number" it prints all the phone
numbers in the report. However, I have been trying to
replace "Phone Number" with an "IF" expression.

I have coded it as follows but cannot get it to work:
IIf([Publish Phone N]="Y",[Phone Number]," ")

Should the If be "If" or "IIf"?

I'm new to using Access.

Thanks, Dick

'cannot get it to work' doesn't give us much information.

= IIf([Publish Phone N]="Y",[Phone Number],"")

should work. Make sure the name of the control is not the same as the
name of one of the fields used in the expression.

If that doesn't help, perhaps you should let us know what it does do.

--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
.
 
J

Jim/Chris

In the OnFormat section of the report try

If me.[Publish Phone N]= "N" Then
me.[Publish Phone N].Visible = False
Else
me.[Publish Phone N].Visible = True
End If

Jim
 

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