Syntax error - =IIf(text Like "0?", "", text) --- =IIf([text] = "0?", Null, "Some Caption Text")

I

Ixak

Hello
I wrote this message:
<<<<<<<<<<<<<<<
Hello,
What I´d like to do is to delete or not to print a data in a label depending
a criteria.
For example:
if visa.text = "0?" then
visa.text =""
end if
Something like that.
Where visa is a label from the report. I try to write this code on the open
event from the report but it doesn´t work. How could I do something like
this?
Thank a lot
I am using access 2003 pro
And I receive two answers:

1.- Third, for something this simple, you don't need any code.
Just set the text box's control source to an expression
like:
=IIf(visa Like "0?", "", visa)
or
=IIf([visa] = "0?", Null, "Some Caption Text")
But I don´t get with the solution. The program says that the expression I
wrote has a not valid syntax.
I have use both, a label and a textbox, but non of them are working.
Thank you very much beforehand
 
D

dcichelli

if you are trying to use the first example, the syntax is wrong:

You wrote: =IIf(visa Like "0?", "", visa)

but it is missing brackets and should be:

= IIf([visa] Like "0?","", [visa])
Hello
I wrote this message:
<<<<<<<<<<<<<<<
Hello,
What I´d like to do is to delete or not to print a data in a label depending
a criteria.
For example:
if visa.text = "0?" then
visa.text =""
end if
Something like that.
Where visa is a label from the report. I try to write this code on the open
event from the report but it doesn´t work. How could I do something like
this?
Thank a lot
I am using access 2003 pro
And I receive two answers:

1.- Third, for something this simple, you don't need any code.
Just set the text box's control source to an expression
like:
=IIf(visa Like "0?", "", visa)
or
=IIf([visa] = "0?", Null, "Some Caption Text")
But I don´t get with the solution. The program says that the expression I
wrote has a not valid syntax.
I have use both, a label and a textbox, but non of them are working.
Thank you very much beforehand
 
I

Ixak

I continue saying that the expression is not valid.
I am writing this code in the source of the control. The message says that
an operator is missing, or that I have input a wrong character, semicolon or
anything without closing the brackets.

Where could I find a tutorial with all this instructions? IIf and code VBA
for MS Access.???
Thanks
Ixak said:
Hello
I wrote this message:
<<<<<<<<<<<<<<<
Hello,
What I´d like to do is to delete or not to print a data in a label
depending
a criteria.
For example:
if visa.text = "0?" then
visa.text =""
end if
Something like that.
Where visa is a label from the report. I try to write this code on the
open
event from the report but it doesn´t work. How could I do something like
this?
Thank a lot
I am using access 2003 pro
And I receive two answers:

1.- Third, for something this simple, you don't need any code.
Just set the text box's control source to an expression
like:
=IIf(visa Like "0?", "", visa)
or
=IIf([visa] = "0?", Null, "Some Caption Text")
But I don´t get with the solution. The program says that the expression I
wrote has a not valid syntax.
I have use both, a label and a textbox, but non of them are working.
Thank you very much beforehand
 
M

Marshall Barton

Ixak said:
I wrote this message:
<<<<<<<<<<<<<<<
Hello,
What I´d like to do is to delete or not to print a data in a label depending
a criteria.
For example:
if visa.text = "0?" then
visa.text =""
end if
Something like that.
Where visa is a label from the report. I try to write this code on the open
event from the report but it doesn´t work. How could I do something like
this?
Thank a lot
I am using access 2003 pro
And I receive two answers:

1.- Third, for something this simple, you don't need any code.
Just set the text box's control source to an expression
like:
=IIf(visa Like "0?", "", visa)
or
=IIf([visa] = "0?", Null, "Some Caption Text")
But I don´t get with the solution. The program says that the expression I
wrote has a not valid syntax.
I have use both, a label and a textbox, but non of them are working.


Please reply in your original thread. It is difficult to
keep track of things when you keep starting new threads.

The second one is wrong because an = comparison does not use
wildcards.

The expression
=IIf(visa Like "0?", "", visa)
must be used in a Text Box's Control Source expression. It
can not be used in a Label because labels do not have a
control source property.

If you are getting a syntax error, I suspect that the
expression you actually used is not the same as what you've
posted. Just to be sure, use Copy and Paste to post the
expression in your text box.

Another thing you should explain is what the name "visa"
represents. It should be the name of a field in the
report's record source table/query or the name of another
text box in the same or an earlier section of the report. I
also need to know if visa is a text string or a number type
(Long, Integer, ??)
 
I

Ixak

Ok. thank you.
The problem persists. What I have is a sale system and I want to print all
the rows, the ones which have been solt and the others also. But I only want
to show some info about those who are solt and the others which are not solt
must appear but not all the info, this is what I want to hide.
By default and for other operations, every row shows visa, which is a money
type data, and cash, same type, and the place.
I want to have a report to show all the products but in those products which
have not been solt I don´t want to see 0?. Example:

Product name Details Place Visa Cash (Sold) --> It is not on
the query, just to explain

Product 1 blue Shop 23? 0? yes
Product2 brown shop 0? 0? no

The source of this report is taken from a query. So the aim is to show
something like this:

Product name Details Place Visa Cash

Product 1 blue Shop 23?
Product2 brown shop

I hope I have explained properly
Thanks a lot for the help
 
M

Marshall Barton

Ixak said:
The problem persists. What I have is a sale system and I want to print all
the rows, the ones which have been solt and the others also. But I only want
to show some info about those who are solt and the others which are not solt
must appear but not all the info, this is what I want to hide.
By default and for other operations, every row shows visa, which is a money
type data, and cash, same type, and the place.
I want to have a report to show all the products but in those products which
have not been solt I don´t want to see 0?. Example:

Product name Details Place Visa Cash (Sold) --> It is not on
the query, just to explain

Product 1 blue Shop 23? 0? yes
Product2 brown shop 0? 0? no

The source of this report is taken from a query. So the aim is to show
something like this:

Product name Details Place Visa Cash

Product 1 blue Shop 23?
Product2 brown shop


Does the Visa field actually have a "?" character? If it
does then, you do need to use the = comparison. If you just
used ? to indicate that there can be exactly one unknown
character after the 0, then use Like. If there may be none
or more than one character after the 0, then use * instead
of ?

Once you figure out what values are in the Visa field and
assuming Vosa os a Text field, you can use the same kind of
expression in all three text boxes"

=IIf(Visa Like "0?", "", Place)
=IIf(Visa Like "0?", "", Visa)
=IIf(Visa Like "0?", "", Cash)
 
D

dcichelli

What is "solt?"


Do you mean "sold?"


Marshall said:
Does the Visa field actually have a "?" character? If it
does then, you do need to use the = comparison. If you just
used ? to indicate that there can be exactly one unknown
character after the 0, then use Like. If there may be none
or more than one character after the 0, then use * instead
of ?

Once you figure out what values are in the Visa field and
assuming Vosa os a Text field, you can use the same kind of
expression in all three text boxes"

=IIf(Visa Like "0?", "", Place)
=IIf(Visa Like "0?", "", Visa)
=IIf(Visa Like "0?", "", Cash)
 

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