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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top