Full Version: Access Report Txtbox And =iff Problem
UtterAccess Discussion Forums > Microsoft® Access > Access Reports
razno
I have report based on query.
In query there is field named Spol

So, i made unbound txtbox and in controlsource i insert = iif([Spol]="Polaznik", "o","la")
and i get The expression you entered contains invalid syntax.

I want txtbox to display o in txt if spol value is Polaznik.

Why it doesn't work?
Peter46
You will have to add Spol to your report (you can make it invisible) in order to use it in an expression.

The alternative is to do this calculation in the reports's recordsource query.
razno
Is in unbound [Spol] name of query field or of control? [txtspol]?

Edit:

nope, same error. I tried to add control based on spol, and name it txt spol.

Invalid exp. i get same in querry and if focus on first "," ---> = iif([Spol]="Polaznik", "o","la")

Edit 2:

in query test: iif([Spol]="Polaznik", "o","la")
razno
Nope, cannot get it to work in report, or query.. what is wrong?


calculation work, something: [somefield]*[somefield], but iif and to return text - does not.
PaulBrand
Use the expression in your query instead of an unbound textbox
razno
QUOTE (PaulBrand @ May 11 2012, 02:00 PM) *
Use the expression in your query instead of an unbound textbox



I never did a iif statement before. Is there i must do something before? do something, activate something?

I have Spol (engl - sex) field in query, all working and displaying results.
In new field in query builder i put without quotes - "test: iif([Spol]="Polaznik","o","la")"
and get syntax error, and first "," after "Polaznik" is selected (i suppose access trying to tell me where is error.
Polaznik = that is word. Spol is sex, polaznik is (male) Student.

I dont get it....
RAZMaddaz
QUOTE (razno @ May 11 2012, 08:32 AM) *
I never did a iif statement before. Is there i must do something before? do something, activate something?

I have Spol (engl - sex) field in query, all working and displaying results.
In new field in query builder i put without quotes - "test: iif([Spol]="Polaznik","o","la")"
and get syntax error, and first "," after "Polaznik" is selected (i suppose access trying to tell me where is error.
Polaznik = that is word. Spol is sex, polaznik is (male) Student.

I dont get it....


You have the right idea, however do it like the following in your new Field:

test: iif([Spol]="Polaznik","o","la")
razno
Ok, i am not home, so i created quick test table, try and get same result....probably doing something stupid so i put a screenshot because picture is worth 1000 words...


(i did put M as male...)
RAZMaddaz
Here is a quick example. Take a look at the Query and see if it similar to what you are trying to do.

RAZMaddaz
razno
Yes, that is what i was trying to do.
Thanks RAZmaddaz

So, problem is that i used "," . Everywhere i looked there is "," (separator)?
Why is that? When is ; and when , needeed?


Thanks again...
RAZMaddaz
So you were using a semi-colon as oppose to a colon?

Glad I could help!!!
cheers.gif

RAZMaddaz
razno
yeah. Im new user, everywhere i looked its was semicolon.

cheers.gif
RAZMaddaz
QUOTE (razno @ May 11 2012, 12:06 PM) *
yeah. Im new user, everywhere i looked its was semicolon.

cheers.gif


Your welcome!!!

Sorry I didn't notice in the picture you uploaded, the semi-colon.

RAZMaddaz
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.