Hi,
Im sure the TRIM function works fine, otherwise there would be thousands of people worldwide kicking up a right fuss. But for some reason it is not returning the desired result.
I have a table with names, the majority are 6 characters long the rest are 5 characters. This data has been copied from a seperate program into excel and the excel file is linked to the access database. This database is then, on a daily basis, appended into an access table.
Now, i am having problems with querying this data as the table has added an extra space onto all fields with 5 characters and will therefore not find the fields with 5 characters.
I have tried using TRIM([name field]) with no avail. After this query has run the spaces are still there.! (i have checked using LEN([name field]) but the figure is still six.)
Does anyone have any idea why this might not work, i have tried using the TRIM command in excel prior to appending the data into the access table but still no luck.
Help is appreciated
8 18841 MMcCarthy 14,534
Recognized Expert Moderator MVP
Hi,
Im sure the TRIM function works fine, otherwise there would be thousands of people worldwide kicking up a right fuss. But for some reason it is not returning the desired result.
I have a table with names, the majority are 6 characters long the rest are 5 characters. This data has been copied from a seperate program into excel and the excel file is linked to the access database. This database is then, on a daily basis, appended into an access table.
Now, i am having problems with querying this data as the table has added an extra space onto all fields with 5 characters and will therefore not find the fields with 5 characters.
I have tried using TRIM([name field]) with no avail. After this query has run the spaces are still there.! (i have checked using LEN([name field]) but the figure is still six.)
Does anyone have any idea why this might not work, i have tried using the TRIM command in excel prior to appending the data into the access table but still no luck.
Help is appreciated
Trim should be working fine. Can you post the sql of the actual query you are using.
Hi,
Im sure the TRIM function works fine, otherwise there would be thousands of people worldwide kicking up a right fuss. But for some reason it is not returning the desired result.
I have a table with names, the majority are 6 characters long the rest are 5 characters. This data has been copied from a seperate program into excel and the excel file is linked to the access database. This database is then, on a daily basis, appended into an access table.
Now, i am having problems with querying this data as the table has added an extra space onto all fields with 5 characters and will therefore not find the fields with 5 characters.
I have tried using TRIM([name field]) with no avail. After this query has run the spaces are still there.! (i have checked using LEN([name field]) but the figure is still six.)
Does anyone have any idea why this might not work, i have tried using the TRIM command in excel prior to appending the data into the access table but still no luck.
Help is appreciated
Trim should work, however you can muscle it by using the Replace() function. -
myfield:replace([name]," ","")
-
luck!
J
Hi,
Unfortunately my company uses Access '97 so the 'Replace' function is unavailable.
The SQL query is: - SELECT [Site Summary].Queue, Trim([Queue]) AS ShortQueue, Len([ShortQueue]) AS Length
-
FROM [Site Summary];
Which should trim each record within the field 'Queue' and then provide the length of the Trimmed record. This is not happenning for some reason.
Its very confusing why this does not work, im assuming that the problem lies with the application the records originate from.
MMcCarthy 14,534
Recognized Expert Moderator MVP
Hi,
Unfortunately my company uses Access '97 so the 'Replace' function is unavailable.
The SQL query is: - SELECT [Site Summary].Queue, Trim([Queue]) AS ShortQueue, Len([ShortQueue]) AS Length
-
FROM [Site Summary];
Which should trim each record within the field 'Queue' and then provide the length of the Trimmed record. This is not happenning for some reason.
Its very confusing why this does not work, im assuming that the problem lies with the application the records originate from.
Are you sure it's not just the Len() function thats not giving the correct number. Have you actually tested the data itself to see if the whitespace is still present.
Anytime a common function such as Trim() fails you have to consider that there's a missing reference! Go into the code module for your form, then goto Tools - References. Check all of the selected references. If any of the selected references are marked "Missing" unselect them, and back out of the dialog box. Now go back into the dialog box and reselect the missing reference(s).
Hi,
Unfortunately my company uses Access '97 so the 'Replace' function is unavailable.
The SQL query is: - SELECT [Site Summary].Queue, Trim([Queue]) AS ShortQueue, Len([ShortQueue]) AS Length
-
FROM [Site Summary];
Which should trim each record within the field 'Queue' and then provide the length of the Trimmed record. This is not happenning for some reason.
Its very confusing why this does not work, im assuming that the problem lies with the application the records originate from.
Here's a Replace String Function for Access 97 posted on the tip page of www.aadconsulting.com
A neat function from Vincent Billard that you can use in Access97, which does not have the native Replace function available in Access2000. Visit Vincent's web site at http://www.rezo.net/skrol29 to download his great V97/V2000 Access add-in. -
Public Function ReplaceString(Str As String, WhatStr As String, WithStr As String) As String
-
'Vincent BILLARD
-
'skrol29@freesurf.fr
-
-
Dim s As String
-
Dim i As Integer
-
-
s = Str
-
i = 1
-
-
If Len(WhatStr) > 0 Then
-
Do Until i > Len(s)
-
If Mid$(s, i, Len(WhatStr)) = WhatStr Then
-
s = Left$(s, i - 1) & WithStr & Mid$(s, i + Len(WhatStr))
-
i = i + Len(WithStr)
-
Else
-
i = i + 1
-
End If
-
Loop
-
End If
-
-
aad_ReplaceString = s
-
-
End Function
-
ADezii 8,834
Recognized Expert Expert
Hi,
Unfortunately my company uses Access '97 so the 'Replace' function is unavailable.
The SQL query is: - SELECT [Site Summary].Queue, Trim([Queue]) AS ShortQueue, Len([ShortQueue]) AS Length
-
FROM [Site Summary];
Which should trim each record within the field 'Queue' and then provide the length of the Trimmed record. This is not happenning for some reason.
Its very confusing why this does not work, im assuming that the problem lies with the application the records originate from.
Are you absolutely positive that the terminating character is a Space and not something similiar to a Null-terminated String where the last character has the ANSI value of 0? To be absolutely sure that the last character in these Strings are spaces, run this simple line of code on these Strings and if the return value is 32, then it is a Space, if not, then we'll have to find out exactly what it is: - Debug.Print Asc(Right(<your string>, 1)) ==> should equal 32 if last character is a Space
If basic string functions aren't working, the file comdlg32.ocx is missing from your C\WINDOWS\SYSTE M32\ folder. Simply copy it from a working computer and paste it into the faulty one. It has worked with pretty much everyone around here who has had VBA missing library problems.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Jan Bols |
last post by:
Whenever I execute TRIM(' ')in a stored procedure or trigger, I get an
ORA-03113 error.
I have an oracle db 8.1.7.0.1 Enterprise edition installed on a
linux-Mandrake 9.1.
EXEMPLE:
I created the function IS_NULL which returns 1 or 0 if the parameter is
empty or not:
|
by: Simon |
last post by:
Hi,
I have written a function to trim char *, but I have been told that my way
could be dangerous and that I should use memmove(...) instead.
but I am not sure why my code could be 'dangerous' or even why there could
be a problem.
here is the code
////////
|
by: Robert Mark Bram |
last post by:
Hi All,
I am using the following trim function:
function trim (str) {
return str.replace(/^\s*/g, '').replace(/\s*$/g, '');
}
The problem is that this doesn't trim instances of the " " char -
the non breaking space. Can this be represented in a grep statement at
|
by: Dave Bovey |
last post by:
I created a church database in Access 97 that contain the typical Name,
Address, and Phone Number information fields. I had a number of
different reports to print query data in different formats.
I had a number of textboxes in the report designs that used the trim()
function to suppress printing of leading spaces. As an example, one of
the textboxes had the following:
=Trim()
Basically, this is looking for a situation where someone...
|
by: Andy B |
last post by:
I've tried using Trim or RTrim to strip trailing space characters from
my data. When I check on the transformed data space characters are
still there.
We have an address table containing two fields: BuildName and
RoadName. Both have the following properties: size 50, not indexed,
not required, allowed zero length. Some records have BuildName,
RoadName as null, some have content. No content is 50 chr long. When i
run a Len(BuildName)...
| |
by: sengkok |
last post by:
I have develop a smart card device reading and writing program, but I am
facing a problem that when I read the value from the smart card, I get "A19\0
\0\0\0", (actually I have store the value A19 into the card from sector 17 to
sector 24, 8 bytes long), I try to use Trim () function to cut the
unnecessary variable to get back the value A19, but it seen that the \0 is
not an null character. I have tried to trim “\0”, but it is not...
|
by: Darren Anderson |
last post by:
I have a function that I've tried using in an if then statement and I've
found that no matter how much reworking I do with the code, the expected
result is incorrect.
the code:
If Not (strIn.Substring(410, 10).Trim = "") Then
'Something processed
Else
'Something processed
|
by: Sascha Herpers |
last post by:
Hi,
what is the difference between the trim function and the trim
String-member?
As far as I see it, both return the trimmed string and leave the
original string unaltered.
Is any of the two faster? Is there a general rule/opinion to prefere
members over functions?
Thanks for any hint.
|
by: Terry Olsen |
last post by:
I have an app that makes decisions based on string content. I need to make
sure that a string does not contain only spaces or newlines. I am using the
syntax 'Trim(String)" and it works fine. I thought I'd change it to the VB
..NET method "String.Trim" but that throws an object exception.
Which brings the question: is it compliant to use Trim(String), or is it
more within etiquette to use If Not String Is Nothing Then String.Trim?
|
by: Marjeta |
last post by:
I'm trying to very that the user actually entered something in the form, and not just spaces.
I guess the problem is in the first line of isBlank() function. I've tried the following: elem.value.trim();
elem.value=elem.value.trim();
elem.value=trim(elem.value);
elem.value.replace(/^\s+|\s+$/g,"");and none works. It correctly gives me an error message if I leave the field completely blank.But if there's anything in the field, it does not...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |