A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Removing empty space character in cell



 
 
Thread Tools Display Modes
  #1  
Old December 18th, 2009, 05:55 PM posted to microsoft.public.access.queries
Booth
external usenet poster
 
Posts: 3
Default Removing empty space character in cell

I've got empty space in my records (ie "abcd ', "efgh " etc) I have tried to
use the find and replace but this is not working

I have also attempted to run an update query to update the cell from
"abcd " to "abcd" but when i do this it just takes out the info and replaces
with a '0'. I am not sure if i have the update to set incorrectly or what. i
have:

"SET myfield"=Replace("myfield"," ","")
  #2  
Old December 18th, 2009, 06:04 PM posted to microsoft.public.access.queries
fredg
external usenet poster
 
Posts: 4,386
Default Removing empty space character in cell

On Fri, 18 Dec 2009 09:55:01 -0800, Booth wrote:

I've got empty space in my records (ie "abcd ', "efgh " etc) I have tried to
use the find and replace but this is not working

I have also attempted to run an update query to update the cell from
"abcd " to "abcd" but when i do this it just takes out the info and replaces
with a '0'. I am not sure if i have the update to set incorrectly or what. i
have:

"SET myfield"=Replace("myfield"," ","")


You've just given us a snippet of the Update SQL with misplaced and
mis-used quotes.
In a query, try it this way:

Update MyTable Set MyTable.[MyField] = Replace([MyField]," ","")

Replace MyTable and MyField with the correct table and field names.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
  #3  
Old December 18th, 2009, 06:34 PM posted to microsoft.public.access.queries
Douglas J. Steele[_3_]
external usenet poster
 
Posts: 3,143
Default Removing empty space character in cell

"fredg" wrote in message
...
On Fri, 18 Dec 2009 09:55:01 -0800, Booth wrote:

I've got empty space in my records (ie "abcd ', "efgh " etc) I have tried
to
use the find and replace but this is not working

I have also attempted to run an update query to update the cell from
"abcd " to "abcd" but when i do this it just takes out the info and
replaces
with a '0'. I am not sure if i have the update to set incorrectly or
what. i
have:

"SET myfield"=Replace("myfield"," ","")


You've just given us a snippet of the Update SQL with misplaced and
mis-used quotes.
In a query, try it this way:

Update MyTable Set MyTable.[MyField] = Replace([MyField]," ","")

Replace MyTable and MyField with the correct table and field names.


Actually, since it looks as though the spaces are at the end of the field
(which surprises me, because Access doesn't normally store trailing spaces),
it might be that all that's required is

Update MyTable Set MyTable.[MyField] = Trim([MyField])


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)



  #4  
Old December 18th, 2009, 06:53 PM posted to microsoft.public.access.queries
Booth
external usenet poster
 
Posts: 3
Default Removing empty space character in cell

when i try this it now just deletes all of the information in my cell? I just
want to delete the space at the end of my information

"fredg" wrote:

On Fri, 18 Dec 2009 09:55:01 -0800, Booth wrote:

I've got empty space in my records (ie "abcd ', "efgh " etc) I have tried to
use the find and replace but this is not working

I have also attempted to run an update query to update the cell from
"abcd " to "abcd" but when i do this it just takes out the info and replaces
with a '0'. I am not sure if i have the update to set incorrectly or what. i
have:

"SET myfield"=Replace("myfield"," ","")


You've just given us a snippet of the Update SQL with misplaced and
mis-used quotes.
In a query, try it this way:

Update MyTable Set MyTable.[MyField] = Replace([MyField]," ","")

Replace MyTable and MyField with the correct table and field names.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
.

  #5  
Old December 21st, 2009, 04:48 PM posted to microsoft.public.access.queries
Booth
external usenet poster
 
Posts: 3
Default Removing empty space character in cell

i just tried

Update MyTable Set MyTable.[MyField] = Trim([MyField])

and when i run the query it deletes all of the values and just leaves the
cells blank....any other thoughts?

"Douglas J. Steele" wrote:

"fredg" wrote in message
...
On Fri, 18 Dec 2009 09:55:01 -0800, Booth wrote:

I've got empty space in my records (ie "abcd ', "efgh " etc) I have tried
to
use the find and replace but this is not working

I have also attempted to run an update query to update the cell from
"abcd " to "abcd" but when i do this it just takes out the info and
replaces
with a '0'. I am not sure if i have the update to set incorrectly or
what. i
have:

"SET myfield"=Replace("myfield"," ","")


You've just given us a snippet of the Update SQL with misplaced and
mis-used quotes.
In a query, try it this way:

Update MyTable Set MyTable.[MyField] = Replace([MyField]," ","")

Replace MyTable and MyField with the correct table and field names.


Actually, since it looks as though the spaces are at the end of the field
(which surprises me, because Access doesn't normally store trailing spaces),
it might be that all that's required is

Update MyTable Set MyTable.[MyField] = Trim([MyField])


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)



.

  #6  
Old December 21st, 2009, 08:13 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default Removing empty space character in cell

That is strange since the VBA function only removes leading and trailing
spaces and nothing else

Just for grins try
Update MyTable Set MyTable.[MyField] = VBA.Trim([MyField])

Or if you want to see the result try a SELECT query and see what is returned

SELECT MyField & "//" as HasSpace
, Trim(MyField) & "//" as RemoveSpace
FROM MyTable

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County

Booth wrote:
i just tried

Update MyTable Set MyTable.[MyField] = Trim([MyField])

and when i run the query it deletes all of the values and just leaves the
cells blank....any other thoughts?

"Douglas J. Steele" wrote:

"fredg" wrote in message
...
On Fri, 18 Dec 2009 09:55:01 -0800, Booth wrote:

I've got empty space in my records (ie "abcd ', "efgh " etc) I have tried
to
use the find and replace but this is not working

I have also attempted to run an update query to update the cell from
"abcd " to "abcd" but when i do this it just takes out the info and
replaces
with a '0'. I am not sure if i have the update to set incorrectly or
what. i
have:

"SET myfield"=Replace("myfield"," ","")
You've just given us a snippet of the Update SQL with misplaced and
mis-used quotes.
In a query, try it this way:

Update MyTable Set MyTable.[MyField] = Replace([MyField]," ","")

Replace MyTable and MyField with the correct table and field names.

Actually, since it looks as though the spaces are at the end of the field
(which surprises me, because Access doesn't normally store trailing spaces),
it might be that all that's required is

Update MyTable Set MyTable.[MyField] = Trim([MyField])


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)



.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:16 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.