Line breaks in an expression, Expression help?

eepok

Noob. Well, mostly noob.
Local time
Yesterday, 23:06
Joined
Oct 30, 2007
Messages
112
Hey all,

I'm creating yet another report for this massive amount of educational data I've collected and need some help combining some of it into an efficiently built report.

My desired outcome is simple:

Instructor1---|Fallcourse1 & Fallcourse1Notes (if any)|WinterCourse1 & Wintercourse1Notes if any)
...................|Fallcourse2 & Fallcourse2Notes (if any)|
...................|Fallcourse3 & Fallcourse3Notes (if any)|
...................|Fallcourse4 & Fallcourse4Notes (if any)|

IF there aren't notes and if there isn't even a class, I would like the space left blank so as not to take up any vertical space in the report.
IF there isn't a course (field is empty), I don't want anything shown.
When viewed in report mode, it will, more or less, look like a spreadsheet with each cell containing up to four courses for each quarter.

Where I am stuck:
-- How do I refer to a field as "empty" or "not empty"?
-- How do I enter a line break into the equation so that there will be a line break in the Report Field if there is a course for which to line break?
-- Is there a way to stop an expression from continuing if a certain variable isn't fulfilled?

I want to say something like
Code:
=iif(
[Fallcourse1] [COLOR="DarkOrange"]is not empty[/COLOR] and [Fallcoursenotes1] [COLOR="DarkOrange"]is not empty[/COLOR], [Fallcourse1]&" - "&[fallcourse1notes], 
(iif([fallcourse1] [COLOR="DarkOrange"]is not empty[/COLOR], [fallcourse1], [COLOR="Green"]STOP[/COLOR]) 
)
[COLOR="DarkRed"]<<LINE BREAK>> [/COLOR]
& iif([Fallcourse2] is not empty, [Fallcourse2]&" - "&[fallcourse2notes]...

I know my equation doesn't work, but I'm just trying to convey my line of thinking with only a half hour left in the day.

Thanks in advance for any help.
 
Last edited:
To test if a field is empty do you mean null or a zero length string? To test a field is null use the IsNull funtion. To check for a zero length string use the Len function. I believe you can use the Chr function to insert a line break ( Chr(32) ) .
 
To test if a field is empty do you mean null or a zero length string? To test a field is null use the IsNull funtion. To check for a zero length string use the Len function. I believe you can use the Chr function to insert a line break ( Chr(32) ) .

So just to clarify, as I am still new to the functions in Access

=iif (
len([field])=0,

would be saying "If field has no characters input"?

And how would I actually implement the "Chr" function? Just follow up with it like I would an HTML tag?
 
Last edited:
Using what nudges in the right direction were provided, I've come up with this expression so far:

Code:
=
IIf( Len([fallcourse1])=0,"", 
          IIf(
               Len([fallcourse1notes])<>0,[fallcourse1] & " - " & [fallcourse1notes],[fallcourse1]
               )
       ) & (Chr(13)) & (Chr(10)) 
& 
IIf(
      Len([fallcourse2])=0,"",
          IIf(
               Len([fallcourse2notes])<>0,[fallcourse2] & " - " & [fallcourse2notes],[fallcourse2]
              )
       ) & (Chr(13)) & (Chr(10))

For future reference to enter a line break (linebreak) into an expression or equation use "& (Chr(13)) & (Chr(10))" appended to the end of the line from which you would like to break
 

Users who are viewing this thread

Back
Top Bottom