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

    Unanswered: Add blank space at end of text box string

    With an Access 2003 form, I am using the keypress event in a text box to enter sentences, and I allow the character if it matches a predetermined letter. It is a text memorization game.
    When a non-letter character, such as space or punctuation follows, the program provides that character and the player will only have to type in letters.
    I have found that when I try to add a space to the text box string of text, it does not take. If I assign the value "The " to the text box, the last character in the text box is "e" when I want it to be a space, and testing in VB shows the length of the text box text is 3.

    I have tried these:
    Me.txtBox.Text = Me.txtBox.Text & " "
    Me.txtBox.Text = Me.txtBox.Text & Chr(32)
    Any ideas?
    Jerry
    Last edited by JerryDal; 12-28-09 at 15:33.

  2. #2
    Join Date
    Sep 2009
    Posts
    44
    Not sure why it's trimming the value for you, but Access will probably let a non-breaking space through. That's Chr$(160) in the normal Latin-1 character set that Windows uses. Just be sure to convert them back to regular spaces when you do something with them.

  3. #3
    Join Date
    Jan 2002
    Location
    Bay Area
    Posts
    511
    Thanks Scooby. Using Chr$(160) to automatically add a blank space, when required, after a predetermined word typed into a text box, does the trick.
    Resolved.
    Last edited by JerryDal; 12-28-09 at 15:22.

Posting Permissions

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