Results 1 to 8 of 8
  1. #1
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328

    Force New Line in columned Report


    I am designing a sub report and would like to force a new line when a condition is met. Only one control in the report, whch is set for 4 columns , structured across then down. The presentation is meant to look like a CSV formatted document.
    I am Using A2007 and A2003.

    I have tried this expression in the query source control so that a new line would be forced if a condition is met.

    IIf([SomeFactor]=1,[ControlName] & " & " & "chr(13)" & " & " & "chr(10)",[controlName]) & “, “


    I have tried it with and without quotes with and without &, I also tried vbLF and vbCR in place of Chr(13) and chr(10).
    even though consensus on visited sites seems to be that vb-- expressions are for visual basic only.

    The few answers that I have found by googling various help sites mostly don't cover what to put in the query. The one or two that do just don't work (inluding this site)
    Can someone tell me what simple thing I am missing?

    Any help much appreciated.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,640
    Don't put the Chr() functions in quotes, they are treated as literal strings if you do.

    ControlName & IIf([SomeFactor]=1, Chr(13) & Chr(10), "") & ", "
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328
    Thanks for quick reply. I put the above expression in the query, but the report still doesn't give me a new line when it encountersthe vlaue with the CHR() statements. Is there something I should be doing with the report?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,640
    Does it show the multi-lines in query? If so, it should carry over to report but I did not test. You could try expression in textbox ControlSource instead of in query.

    If you want to provide db for analysis, follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328

    Attached

    I tried inserting Chr() etc. in the control box in the report, still no new line. Please don't analyze the table. In real life there is a lot of stuff in front of this simplified table. I made it this way to focus on what we are talking about, i.e., force a new line in a columned report if a condition is met. Thanks much for inviting me to send this to you, your help is much appreciated.
    Attached Files Attached Files

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,640
    The expression does not concatenate anything after the Chr(13) & Chr(10). What do you want to follow the CrLf?

    ReptContrCHR: IIf([frac]=1, [item] & Chr(13) & Chr(10) & "something here", [QuanItem])
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328
    I se now that I was putting the LF in wrong place relative to the data. However, this doesn't work either. If I put expression within the report control, it just gives me a new line within the control, not a new line in the report (which maybe I didn't make clear that that what I was trying to do). I have been trying to avoid a cross tab query, but will go that route. Thanks much for taking time with this.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,640
    Oh, no, can't add a 'line' in report that way.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. DCount on report - per line
    By justinwright in forum Reports
    Replies: 4
    Last Post: 04-13-2012, 10:38 AM
  2. Line chart in access report
    By drp in forum Reports
    Replies: 2
    Last Post: 11-29-2011, 09:37 AM
  3. Replies: 3
    Last Post: 11-13-2011, 10:20 PM
  4. Select line from a form for a report
    By drf3794 in forum Access
    Replies: 3
    Last Post: 03-17-2011, 11:01 AM
  5. Replies: 3
    Last Post: 03-24-2006, 08:40 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums