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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing all spaces from a field in query 1

Status
Not open for further replies.

VBAguy22

IS-IT--Management
Aug 5, 2003
180
CA
Hi,
I have a table that has a field that contains spaces. I would like to remove all spaces from that field. Is there a built in function in Access to do that in a query?

Eg:
I have: "this is an example"
I want: "thisisanexample"

Thanks!
 
If access 2k or above, create the following function in a standard code module:
Code:
Public Function myReplace(myString, myFind As String, myRepl As String)
If Trim(myString & "") <> "" Then
  myReplace = Replace(myString, myFind, myRepl)
End If
End Function

And now in the query grid:[tt]
trimmedfield: myReplace([field name], ' ', '')[/tt]

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top