Results 1 to 4 of 4
  1. #1
    Join Date
    May 2004
    Posts
    133

    Talking Unanswered: remove first space from string

    Hiiiiiiiiiiiiii,
    For example I have a form with field: "employee_name".
    When people input empoyee name into it, ex: "John Smith".
    Sometime there is a space in the front of the string like this: " John Smith".
    How can I remove that space programatically? Could anyone advice me
    about this?
    For instance: which event should I use? method etc.
    If you have a little of free time, could you decribe as detail as you can
    about the way to solve problem?
    thanks

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    Here is one way....

    Copy and paste the following code into a database code module:
    Code:
    Public Function PreventFirstSpace(Ctrl As Control, X As Integer) As Integer
       If Len(Ctrl.Text) = 0 And X = 32 Then
    	  PreventFirstSpace = 0
       Else
    	  PreventFirstSpace = X
       End If
    End Function
    Then in the Key Down event for any control you enter text, copy and past this code:

    Code:
       KeyCode = PreventFirstSpace(Me.myTextBoxName, KeyCode)
    .
    Environment:
    Self Taught In ALL Environments.....And It Shows!


  3. #3
    Join Date
    May 2004
    Posts
    133
    Thanks. it works

  4. #4
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    what about Trim() ?
    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
  •