Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datasheet view form - prevent "space,space" 1

Status
Not open for further replies.

micang

Technical User
Aug 9, 2006
626
US
MS Access 2007

Hi All,

I have a datasheet form with one of the fields that when "space, space" (i.e. hitting the spacebar twice and creating 2 blank characters) get's typed, it needs prevent this.

Or, not even that important to be done while a user is typing, it will also suffice to have a check n place that I can run after (i.e. a piece of vba script).

My problem is I can't figure out how to identify if the field contains "space,space"?

Any info will be very appreciated.

Many thanks.

Michael
 
I can't figure out how to identify if the field contains "space,space"?
Have a look at either the InStr function or the Like operator.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV,

Thank you so much for the lead, have managed to use the Like operator to achieve what I needed.

Much appreciated.

Michael
 
Just FYI: You can also use this:

Me.Text1 = Replace(Me.Text1, " ", " ", 1, -1)

If you have problems with people entering 3 or more spaces, you can just put the above code in a loop and it'll squish any number of consecutive spaces down to one. Of course, you'd need a terminating condition for a loop, so the InStr() function would work for that.

Something like this:

Do Until InStr(1, Me.Text1, " ") = 0
Me.Text1= Replace(Me.Text1, " ", " ", 1, -1)
Loop

BobK

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top