Need help with expression using LEFT$

  • Thread starter Thread starter connie
  • Start date Start date
C

connie

I have tried this every way I can think of and nothing
works.

In a report (access 97) I have a check box field in which
I want it to accomplish the following:

If the left 3 characters of the [type] field = "COS" then
this box should appear checked, otherwise it shouldn't.

I tried this expression in the control source property
for the field in the report, but I get a message that an
IIF expression has to be in parenthesis. If this isn't
right, what is?

=IIF Left$([type],3="COS",True,False)
 
Thanks for the response, but that leaves out the IIF
statement I need in there. If the first 3 characters are
COS then a checkmark should appear, otherwise it's blank.

-----Original Message-----
Try a control source of:
=Left([type],3)="COS"
--
Duane Hookom
Microsoft Access MVP


connie said:
I have tried this every way I can think of and nothing
works.

In a report (access 97) I have a check box field in which
I want it to accomplish the following:

If the left 3 characters of the [type] field = "COS" then
this box should appear checked, otherwise it shouldn't.

I tried this expression in the control source property
for the field in the report, but I get a message that an
IIF expression has to be in parenthesis. If this isn't
right, what is?

=IIF Left$([type],3="COS",True,False)


.
 
Connie,
1) Well, you did leave out the parentheses after the IIf.
You wrote:
=IIF Left$([type],3="COS",True,False)

It should be:

=IIF(Left$([type],3="COS",True,False)

2) If you had tried Duanes expression,

=Left([type],3)="COS"

you would have found it did work.
You don't need the IIf() if you do it his way.
The check box expression evaluates the left 3 characters of the Type field.
If they = "COS" the expression is true, and the check box prints with the
check. Otherwise the expression is false and the check box does not print
the check.

I'd suggest you try the code given you in the future, before jumping to a
conclusion.
Often, in Access, there is more than one way to do something.
--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.


connie said:
Thanks for the response, but that leaves out the IIF
statement I need in there. If the first 3 characters are
COS then a checkmark should appear, otherwise it's blank.

-----Original Message-----
Try a control source of:
=Left([type],3)="COS"
--
Duane Hookom
Microsoft Access MVP


connie said:
I have tried this every way I can think of and nothing
works.

In a report (access 97) I have a check box field in which
I want it to accomplish the following:

If the left 3 characters of the [type] field = "COS" then
this box should appear checked, otherwise it shouldn't.

I tried this expression in the control source property
for the field in the report, but I get a message that an
IIF expression has to be in parenthesis. If this isn't
right, what is?

=IIF Left$([type],3="COS",True,False)


.
 
connie,
Correction to my previous post:
=IIF(Left$([type],3="COS",True,False)
Should read
=IIF(Left$([type],3)="COS",True,False)

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.


Fredg said:
Connie,
1) Well, you did leave out the parentheses after the IIf.
You wrote:
=IIF Left$([type],3="COS",True,False)

It should be:

=IIF(Left$([type],3="COS",True,False)

2) If you had tried Duanes expression,

=Left([type],3)="COS"

you would have found it did work.
You don't need the IIf() if you do it his way.
The check box expression evaluates the left 3 characters of the Type field.
If they = "COS" the expression is true, and the check box prints with the
check. Otherwise the expression is false and the check box does not print
the check.

I'd suggest you try the code given you in the future, before jumping to a
conclusion.
Often, in Access, there is more than one way to do something.
--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.


connie said:
Thanks for the response, but that leaves out the IIF
statement I need in there. If the first 3 characters are
COS then a checkmark should appear, otherwise it's blank.

-----Original Message-----
Try a control source of:
=Left([type],3)="COS"
--
Duane Hookom
Microsoft Access MVP


I have tried this every way I can think of and nothing
works.

In a report (access 97) I have a check box field in which
I want it to accomplish the following:

If the left 3 characters of the [type] field = "COS" then
this box should appear checked, otherwise it shouldn't.

I tried this expression in the control source property
for the field in the report, but I get a message that an
IIF expression has to be in parenthesis. If this isn't
right, what is?

=IIF Left$([type],3="COS",True,False)


.
 
Back
Top