No space in front of Name

  • Thread starter Thread starter JayTee
  • Start date Start date
J

JayTee

Hi all,
I am looking for help with a field in a database that some people like to
enter a space before a name into it.
I know that the code If KeyAscii = vbspace then keyascii = 0 omits spaces
but I only want the first space eliminated in case they enter one.
The spaces causes havoc when searching.
Thanks in advance to any one that can assist me.

JT
 
The Trim() function will do what you wish. LTrim() will eliminate any
leading spaces so:

Private Sub MyTextbox_AfterUpdate()
Me.MyTextbox = LTrim(Me.MyTextbox)
End Sub
 
Back
Top