Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!
  1.   Become a Supporter    ::   Make a Contribution   
    Target (Recurring Monthly): $200 :: Achieved: $98

Removing Extra Space (with a twist)

Discussion in 'Information Technology' started by Richard, Jul 28, 2006.

  1. Richard

    Richard
    Expand Collapse
    Guest

    I know how to handle leading and trailing spaces. But how would you remove an
    extra space (if there is an extra space) in a field that contains First Name
    and Last Name, so that only 1 space is left? Thanks for your help on this one.
     
  2. Loading...


  3. Graham Mandeno

    Graham Mandeno
    Expand Collapse
    Guest

    Hi Richard

    How about:

    txtName = Trim(txtName)
    Do While InStr(txtName, " ") > 0
    txtName = Replace(txtName, " ", " ")
    Loop

    You could put this code in the AfterUpdate event procedure for your textbox
    or, if you prefer, in a separate function.

    I urge you to consider storing first and last name in separate fields. This
    will give you all sorts of advantages such as sorting by last name and
    addressing by first name (Dear Richard) to name but two.
    --
    Good Luck!

    Graham Mandeno [Access MVP]
    Auckland, New Zealand

    "Richard" <Richard@discussions.microsoft.com> wrote in message
    news:7965518B-E268-40E5-BD51-67211F38D807@microsoft.com...
    >I know how to handle leading and trailing spaces. But how would you remove
    >an
    > extra space (if there is an extra space) in a field that contains First
    > Name
    > and Last Name, so that only 1 space is left? Thanks for your help on this
    > one.
     
  4. Richard

    Richard
    Expand Collapse
    Guest

    Thank you Graham

    "Graham Mandeno" wrote:

    > Hi Richard
    >
    > How about:
    >
    > txtName = Trim(txtName)
    > Do While InStr(txtName, " ") > 0
    > txtName = Replace(txtName, " ", " ")
    > Loop
    >
    > You could put this code in the AfterUpdate event procedure for your textbox
    > or, if you prefer, in a separate function.
    >
    > I urge you to consider storing first and last name in separate fields. This
    > will give you all sorts of advantages such as sorting by last name and
    > addressing by first name (Dear Richard) to name but two.
    > --
    > Good Luck!
    >
    > Graham Mandeno [Access MVP]
    > Auckland, New Zealand
    >
    > "Richard" <Richard@discussions.microsoft.com> wrote in message
    > news:7965518B-E268-40E5-BD51-67211F38D807@microsoft.com...
    > >I know how to handle leading and trailing spaces. But how would you remove
    > >an
    > > extra space (if there is an extra space) in a field that contains First
    > > Name
    > > and Last Name, so that only 1 space is left? Thanks for your help on this
    > > one.

    >
    >
    >
     
Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     



Share This Page