Remove Tab char

Freshman

Registered User.
Local time
Today, 16:58
Joined
May 21, 2010
Messages
437
Hi all,

I've got a Excel SS with a field that appears to contain a number eg: 0059 with some trailing spaces.
I'm trying to get rid of the trailing spaces but trim or replace just don't do it.
When I copy the field to a notepad I get a " followed by a <Tab> and then 0059 followed by another <Tab> space and then another " at the end.

So it seems like there is a "hidden" tabs characters on either side.
How on earth do I get rid of those in an Access update query.

Thanks
 
Answering my own question thanks to my buddy Google.
Replace([Field],Chr(9),"")

Cheers
 
Tab character is Chr(9), so you can replace that with an empty string . . .
Code:
Replace(<string with tabs>, Chr(9), "")
 
Actually, looks like I was a few minutes late with that solution. :) Glad you got it figured out!
 
@Galzxiom - Thanks - that is exactly the problem I had to overcome. The 2 tabs on either side of the text are in the Excel spreadsheet that is how I import from a 3rd party Payroll software app.
It boggled my mind when I tried to get rid of what I though was spaces as you have no real way of seeing it is tabs while in Excel. It was only when I, almost by accident, copied the text to Notepad that I saw the tabs.
What a mess hey!
Was easy to fix once I knew what I had to replace as replacing a space does nothing to a tab :)
 
Interesting! I had a problem with new values entered into a table not sorting correctly. It's only while I was posting a question in this forum that I saw that the old data (imported from FoxPro) had double quotes and tabs inserted.

Looking at the data in Excel, or pasting it into Word (keeping formatting) showed nothing weird. Pasting into Notepad showed something strange. Pasting into Word as plain text enabled me to identify the extraneous characters.
 
note also that trim() and its buddies ltrim() and rtrim() will remove unnecessary leading and trailing spaces from text fields
 
If you might have strange characters in a string and you don't know what they might be, you have to loop through the variable, character by character and copy out the valid characters - letters, numbers, and any special characters that are allowed - into a separate variable. Then use the extracted variable to continue processing.
 

Users who are viewing this thread

Back
Top Bottom