Results 1 to 8 of 8
  1. #1
    Join Date
    Jan 2002
    Location
    Bay Area
    Posts
    511

    Question Unanswered: Words are split in text box

    In my Access 2003 form, I procedurally accumulate text in a text box from sentences that the user types in another text box. When I store the text, a word may be split to a following line. Is this text box behavior (the splitting of words at the end of a line) that I will have to live with?
    Jerry

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Depends on your procedure...

    Could be an artifact of how you're capturing the "sentences".
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Jan 2002
    Location
    Bay Area
    Posts
    511
    Text is captured in the keypress event of a text box. In the same event, after the expected sentence of words is captured, data is assigned to a variable and written to a larger text box, where words at the end of a line can be split between lines. I get split words with and unbound text box and I also tried a text box that has an empty table's memo field as the control source with the same results.

    I set up a command button to assign a long string of text to the text box and got split words, such as:
    Me.txtBoxName.SetFocus
    Me.txtBoxName.Text = "blah, blah, blah, blah, etc. (a long string of words) ..."

    When I type into the text box, the box behaves and does not split words between lines.

    Jerry
    Last edited by JerryDal; 12-31-09 at 01:13.

  4. #4
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Please elaborate on this part:

    data is assigned to a variable and written to a larger text box
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  5. #5
    Join Date
    Jan 2002
    Location
    Bay Area
    Posts
    511
    I am developing a tool for memorizing verses. The user types into a text box, and the keypress event for that box accepts only the correct letters. The code (in the keypress event) fills in punctuation and spaces where needed and does upper and lower case for the typist. I learned from this forum that I needed to use Chr(160) for VBA to add a space after a word in a text box, and I found that trying to add a space using Chr(32) or " " just goes away when added to the end of a string. In a test, I assigned a long string to a text box and got split words, which shows that the choice of Chr(160) vs " " or Chr(32) is not causing the splitting. After the verse is correct and complete, I assign it to a variable and accumulate it into a larger text box, using code similar to this:
    typedString = Me.txtBox1Name.Text
    Me.txtSaved.Setfocus 'the larger text box accumulates all typed verses
    Me.txtSaved.Text = Me.txtSaved.Text & vbCrLf & typedString
    The problem is that text assigned to a text box in this way produces split words at the ends of lines. Text typed into a text box does not split words.
    Jerry

  6. #6
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    vbCrLf is a line feed... It's equivalent to "Chr(10) & Chr(13)"...

    Is txtSaved bound? It could be that it's trimming the space from the end of the value if it's being persisted.. This SHOULD work:

    Me.txtSaved.Text = Me.txtSaved.Text & " " & typedString

    You can absolutely add a space to the end of a string without any shenanigans. What leads you to believe this was causing an issue?



    Edit: To be more concise, you are explicitly adding line breaks. That's why there is a line break.
    Last edited by Teddy; 01-01-10 at 19:40.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  7. #7
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    I wonder if the insertion of a hard space / non breaking space was blowing something in the control?
    I'd rather be riding on the Tiger 800 or the Norton

  8. #8
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    I'd be more inclined to believe it would have to do with trimming the string when it's persisted to the database (ala: ANSI_PADDING in SQL Server) rather than something to do with programmatic manipulation of strings like we're dealing with here.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •