Results 1 to 4 of 4
  1. #1
    Peter1 is offline Novice
    Windows 8 Access 2007
    Join Date
    Apr 2016
    Location
    Budapest
    Posts
    2

    Can't change "1 200" to "1200" with replace() function

    Hi,

    VBA code.

    Dim sh_cost_txt As String (or tried As Variant, but doesn't work either....)

    Pick up the value from a field with string manipulation functions and assign it to sh_cost_txt, now it's value is "1 200" (including a space within)

    Would like to have it without the space, so using the replace() funcion:
    replace(sh_cost_txt, " ", "") but it displays: "1 200" in the immediate window, which means it did not replaced the space character with an empty character.

    When asking:


    ?replace("1 200"," ","")
    it correctly says:
    1200

    When asking:
    ?replace(sh_cost_txt," ","")
    it says:
    1 200

    ..... WHY????

    Please help.

    Thanks,
    Peter

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    It may be a non-breaking space. Try Replace() with Chr(160).
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Peter1 is offline Novice
    Windows 8 Access 2007
    Join Date
    Apr 2016
    Location
    Budapest
    Posts
    2
    Dear Paul,

    You're right, it was indeed! Thanks much!
    (sad thing's that it was myself who added the nonbreaking space into those fields for some other reason, but forgot about it by now... :-)

    Thanks much again for your help.

    Peter

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Happy to help Peter, and welcome to the site!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 1
    Last Post: 09-07-2015, 08:00 AM
  2. Replies: 1
    Last Post: 09-03-2014, 03:27 AM
  3. Replies: 30
    Last Post: 09-27-2013, 01:34 PM
  4. Replies: 2
    Last Post: 11-04-2011, 02:45 AM
  5. Replies: 3
    Last Post: 04-10-2010, 10:22 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