No space in front of Name

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
 
B

Benjamins via AccessMonster.com

Hi,

You can try the trim(string) and it will trim off any space infront as well
as behind.
 
A

Arvin Meyer [MVP]

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
 
Top