Non-printing character in table (1 Viewer)

RogerCooper

Registered User.
Local time
Today, 01:04
Joined
Jul 30, 2014
Messages
286
I have an Access native table which contains information cut & pasted from a website. When that happens, sometimes you get spaces that can be easily trimmed. Other times I get weird things like this.

Image from screen

1673549680719.png


Cutting and pasting the rows
Query1 Query1
Query1 Query1

Invoice NumberLast CharacterAsc Value LastField LengthFirst CharacterAsc Value First
53341137988
56​
11​
9​
53341137988
56​
10​
5
53​
Here is the query code
Code:
SELECT [UPS Supply Chain Bills].[Invoice Number], Right([Invoice Number],1) AS [Last Character], Asc(Right([Invoice Number],1)) AS [Asc Value Last], Len([INvoice Number]) AS [Field Length], Left([Invoice Number],1) AS [First Character], Asc(Left([Invoice Number],1)) AS [Asc Value First]
FROM [UPS Supply Chain Bills]
WHERE ((([UPS Supply Chain Bills].Amount)=432.88));

It looks like a <TAB> character has gotten in. How can I remove it automatically or prevent it from be entered in the first place?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 01:04
Joined
Oct 29, 2018
Messages
21,473
Not sure about preventing if you're pasting data. Otherwise, you can use an UPDATE query to fix it. Look up both the Asc() and Chr() functions.
 

plog

Banishment Pending
Local time
Today, 03:04
Joined
May 11, 2011
Messages
11,646
You always want to find a general rule and work with that. You've only given us 1 example but using that I see this:

The invoice number is the last 10 characters of the pasted value.

If that's true, a simple Right() will get those 10 characters and you don't have to worry about looking for specific ascii values or testing the length of the string. If that's not true, try and find a general rule that does work and then code for that.
 

ebs17

Well-known member
Local time
Today, 10:04
Joined
Feb 7, 2020
Messages
1,946
If you know what you want to eliminate:
Code:
Replace("Yourstring", Chr(9), "")

If you don't know exactly what you need to eliminate, but only want to keep certain characters such as letters, digits, underscores, regular expressions, e.g. with a search pattern, will help you...
Code:
[^a-zA-Z_0-9]
 
Last edited:

RogerCooper

Registered User.
Local time
Today, 01:04
Joined
Jul 30, 2014
Messages
286
If you know what you want to eliminate:
Code:
Replace("Yourstring", Chr(9), "")

If you don't know exactly what you need to eliminate, but only want to keep certain characters such as letters, digits, underscores, regular expressions, e.g. with a search pattern, will help you...
Code:
[^a-zA-Z_0-9]
Thank you, first option worked well.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 09:04
Joined
Sep 12, 2006
Messages
15,656
It may not always be safe to just remove the rightmost character.
You really need to find out what is causing this.

chr(9) is a tab, so someone or something is inserting a tab at the start of the string.
 

RogerCooper

Registered User.
Local time
Today, 01:04
Joined
Jul 30, 2014
Messages
286
When you copy and paste from a website, you can get strange characters. I don't see any way of preventing that.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 16:04
Joined
May 7, 2009
Messages
19,243
you use a Form for your table and add call a function that will "clean" your string
before it got saved.
 

Users who are viewing this thread

Top Bottom