Results 1 to 6 of 6
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington, Cheshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Strange character (2003)

    I just know that the answer to this is going to be embarrassingly simply but . . .
    I have two variables (strFirst and strLast) declared as string. Each is used in a Dlookup statement to get a first name and last name.
    I have an unbound text box (LMText) on a report to which I wish to assign the name.
    If the VBA is Me.LMText = strFirst & " " & strLast , results look like Fred Smith
    As I'm having trouble with getting enough width to print the name, I decided to remove the space, put in a new line and make the text box double height.
    So now the VBA looks like Me.LMText = strFirst & Chr(13) & strLast , but the output is FredSmith i.e. there's an unprintable character not a new line.
    What have I done wrong, please?
    Thanks
    Silverback
    Silverback

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,326
    Thanks
    1
    Thanked 12 Times in 12 Posts

    Re: Strange character (2003)

    You might want to make it:

    Me.LMText = strFirst & vbCrLf & strLast

    "vbCrLF" is the intrinsic constant for "Carriage Return and Line Feed".
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington, Cheshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Strange character (2003)

    Thank you! <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15>
    All OK now, but why?
    Silverback
    Silverback

  4. #4
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,326
    Thanks
    1
    Thanked 12 Times in 12 Posts

    Re: Strange character (2003)

    Because chr(13) is just a Carriage Return, you also need the Line Feed character , which is chr(10).
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  5. #5
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington, Cheshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Strange character (2003)

    Did not know that. I've been using Chr(13) in MsgBox and it'sbeen giving CrLf, so I just kept on using it.
    Many thanks, again
    Silverback.
    Silverback

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Strange character (2003)

    You have to learn by heart what each application uses, there is no consistency:
    - Word uses vbCr = Chr(13) as paragraph break.
    - Excel uses vbLf = Chr(10) as line break.
    - Access uses vbCrLf = Chr(13) & Chr(10) as line break.

Posting Permissions

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