Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Expression Syntax 1

Status
Not open for further replies.

Overmyhead2

Programmer
Jun 5, 2000
39
US
I have 2 bound fields - Percent and Data.
I need to separate the Data into two columns.

I have 2 unbound text boxes. 50andOver and Under50.
I want [50andOver] to equal [Data] if [Percent] => 50 else I want [50andOver] to equal "0".

I want [Under50] to equal [Data] if [Percent] < 50 else I want [Under50] to equal &quot;0&quot;.

I'm using an expression for the control source for the text boxes. Things I've tried:
---------------------------------------------
=if [Percent] < &quot;50&quot; ,[Data],&quot;0&quot;
---------------------------------------------
= if [Percent] < &quot;50&quot; then [Under50]=[Data] else [Under50]=&quot;0&quot; endif
 
If statements in Access are

Iif(test,true,false)

so you would use:

=Iif([percent]<&quot;50&quot;,[Data],&quot;0&quot;)

This is assuming that percent is a text datatype. If it is a numeric, you probably don't need the quotes around the 50.


Hope this helps.

Kathryn


 
Thanks for respounding! The syntax looks good but when I run the report..I get boxes popping up asking me for IF...
Percent... Any ideas. My report is Bound to a DateRange query.
 
Could you copy and paste the EXACT syntax from the control source? Do all the fields referenced in your Iif statement exist in the Query?

Kathryn


 
this is the query record source for the Report---

SELECT DISTINCTROW ASPData.ServeDate, ASPData.Paid, ASPData.Reduced, ASPData.Free, ASPData.ASNumber, ASPNames.Site, ASPNames.AsName, ASPNames.PrecertFree
FROM ASPNames RIGHT JOIN ASPData ON ASPNames.ASNumber = ASPData.ASNumber
WHERE (((ASPData.ServeDate) Between [Forms]![ASPData].[StartDate] And [Forms]![ASPData].[EndDate]));

This is the if statement...
=If([DateRange]![PrecertFree]<50,[DateRange]![Free],0)
..On this one I get three extra boxes popping up.. IF, PercentFree, DateRange

And I tried:
=If([PrecertFree]<50,[Free],0)
...On this one I get 2 extra boxes popping up... IF, PercentFree
 
OK, that was what I thought. &quot;If&quot; is not correct in Access, you must use &quot;Iif&quot;. Don't ask why, it's one of those things you have to get used to. In code, you use &quot;If&quot;.

If the Iif statements are in the report, you don't need the [DateRange]! before Fee.

I hope this is just a typo, but on my screen your first If statent has PercertFee instead of PercentFee.

Kathryn


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top