Results 1 to 15 of 15
  1. #1
    CORINEREYES is offline Novice
    Windows 11 Access 2016
    Join Date
    Jan 2023
    Posts
    18

    VbNewline or arrange text in a textbox as paragraph

    Hi Everyone,

    Good day!

    I have this simple program that generates notes or sentences in a text box. My issue is i can not format the words or text in the textbox as like paragraph or sentence. I need to bring down some text in it at the top middle and bottom of the text box. Can someone please assist me?

    Im currently using this code in a command button.



    Code:
    txtNotes = FGreetings & " " & vbNewLine & Reason & " " & EGreetings & " " & Sname
    Thank you in advance,
    Corine

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    No idea what you're asking for. I suggest you post what you have in your textbox as well as what you want it to be. Copy/paste from Excel sheet if you want a quick and easy table in your post.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Can also copy/paste from Access table.

    What does "in it at the top middle and bottom of the text box" mean? Perhaps a picture would be helpful.


    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.

  4. #4
    CORINEREYES is offline Novice
    Windows 11 Access 2016
    Join Date
    Jan 2023
    Posts
    18
    Hi Micron,

    This is a screenshot of my form in access, basically there are combo boxes , combo box contains values , you select the phrase you want then it will be displayed in the text box (note) that will generate a simple letter. As you can see, i need the body of the letter to be 2 lines after the first greeting and the end greeting 2 lines below the body of the letter and so on. I wanted a carriage return after those liines i mentioned.
    Attached Thumbnails Attached Thumbnails Screenshot 2023-07-07 195158.png  
    Last edited by CORINEREYES; 07-07-2023 at 11:00 AM. Reason: forgot to post the pic

  5. #5
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    Usual way would be to use vbcrlf

  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Not sure what you are asking here?
    You know the constant to get a new line.
    You know the controls and what they contain, so you know where that constant should go?

    What else are you asking?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  7. #7
    CORINEREYES is offline Novice
    Windows 11 Access 2016
    Join Date
    Jan 2023
    Posts
    18
    Quote Originally Posted by CORINEREYES View Post
    Hi Micron,This is a screenshot of my form in access, basically there are combo boxes , combo box contains values , you select the phrase you want then it will be displayed in the text box (note) that will generate a simple letter. As you can see, i need the body of the letter to be 2 lines after the first greeting and the end greeting 2 lines below the body of the letter and so on. I wanted a carriage return after those liines i mentioned.
    Hi All, sorry for the confusion, i just want to achieve this. Instead of the one i attached before. The event should happen when i press the transfer button.
    Attached Thumbnails Attached Thumbnails Screenshot 2023-07-07 211654.png  

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I use vbCrLf, never used vbNewLine. However, seem to produce same result.

    Concatenate as many as needed to achieve desired spacing.

    Don't even need VBA. Expression in textbox ControlSource could work.

    Is this letter a report object?
    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.

  9. #9
    CORINEREYES is offline Novice
    Windows 11 Access 2016
    Join Date
    Jan 2023
    Posts
    18
    Hi June7,

    i use this code , but i does not work. Is there anything I'm missing?

    Code:
    txtNotes = FGreetings & " " & vbCrLf & Reason & " " & EGreetings & " " & Sname

  10. #10
    CORINEREYES is offline Novice
    Windows 11 Access 2016
    Join Date
    Jan 2023
    Posts
    18
    i can try this, and re arrange all but is there something i needed to enable from the text box properties? I have seen a lot of codes like the one i have and it works. but mine does not.

  11. #11
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,654
    If your trying to generate form letters, take a look at Albert Kallal's super easy word merge

    http://www.kallal.ca/msaccess/msaccess.html
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  12. #12
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Re the none working expression: I don't think control is exposed to vba that way. On my phone so can't test. Could try
    ... & Chr(13) & Chr(10) &... instead.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  13. #13
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    Are you using richtext in your txtnotes control? If so you need to be using html code for things like carriage returns

  14. #14
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    What does "not working" mean - error message, wrong result, nothing happens?

    What is txtNotes - a field in table or just an unbound textbox?

    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.

  15. #15
    CORINEREYES is offline Novice
    Windows 11 Access 2016
    Join Date
    Jan 2023
    Posts
    18
    Quote Originally Posted by CJ_London View Post
    Are you using richtext in your txtnotes control? If so you need to be using html code for things like carriage returns
    this solves the issue! i used vbcrlf and vbnewline! it should be Plain text only.

    Thanks a lot for all your suggestions and help! much appreciated

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

Similar Threads

  1. Replies: 3
    Last Post: 05-22-2019, 12:25 PM
  2. Adding vbnewline to a text string
    By Dave_D in forum Access
    Replies: 12
    Last Post: 10-18-2018, 02:21 PM
  3. Replies: 3
    Last Post: 02-01-2018, 03:10 AM
  4. Replies: 6
    Last Post: 02-26-2016, 05:28 AM
  5. Arrange subreport
    By Ray67 in forum Reports
    Replies: 1
    Last Post: 07-25-2012, 01:34 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