473,398 Members | 2,525 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

RTrim / LTrim query question

Arvo,

I've been reading about the above function, or similar, as it seems
applicable to my problem, however I have to admit I am totally lost.
What I need to do is update about 330 records that are currently in
the format "abc-xyz", all currently in a field called Type. I would
like to keep the "abc" text in the Type field and move/cut the "xyz"
text into a Description field. I only need to update the date once,
validate it is OK and then forget I ever did it ;-)

I think I'm making this harder than needed.

Regards,

Stinky Pete ;-)

Nov 13 '07 #1
4 7215
On Mon, 12 Nov 2007 18:43:44 -0800, Stinky Pete
<Pe**********@symbionhealth.comwrote:

What do you mean by "I only need to update the date once,
validate it is OK"?
So far you're not working with date fields.
What kind of validation did you have in mind?

On another topic: a field named "Type" is a bad idea, because it is a
reserved word. You can only successfully use it if you always remember
to put square brackets around it.

-Tom.

>Arvo,

I've been reading about the above function, or similar, as it seems
applicable to my problem, however I have to admit I am totally lost.
What I need to do is update about 330 records that are currently in
the format "abc-xyz", all currently in a field called Type. I would
like to keep the "abc" text in the Type field and move/cut the "xyz"
text into a Description field. I only need to update the date once,
validate it is OK and then forget I ever did it ;-)

I think I'm making this harder than needed.

Regards,

Stinky Pete ;-)
Nov 13 '07 #2
On Mon, 12 Nov 2007 18:43:44 -0800, Stinky Pete wrote:
Arvo,

I've been reading about the above function, or similar, as it seems
applicable to my problem, however I have to admit I am totally lost.
What I need to do is update about 330 records that are currently in
the format "abc-xyz", all currently in a field called Type. I would
like to keep the "abc" text in the Type field and move/cut the "xyz"
text into a Description field. I only need to update the date once,
validate it is OK and then forget I ever did it ;-)

I think I'm making this harder than needed.

Regards,

Stinky Pete ;-)
Where comes ltrim or rtrim in the picture?

You can use split :
?split("abc-xyz","-")(0)
abc
?split("abc-xyz","-")(1)
xyz
--
Recards
Benny Andersen
Nov 13 '07 #3
Stinky Pete wrote:
Arvo,

I've been reading about the above function, or similar, as it seems
applicable to my problem, however I have to admit I am totally lost.
What I need to do is update about 330 records that are currently in
the format "abc-xyz", all currently in a field called Type. I would
like to keep the "abc" text in the Type field and move/cut the "xyz"
text into a Description field. I only need to update the date once,
validate it is OK and then forget I ever did it ;-)

I think I'm making this harder than needed.

Regards,

Stinky Pete ;-)
Trim functions are about removing leading and trailing spaces and have nothing
to do with your issue. Look at the help file for descriptions of the
functions...

Left() grabs text from the left of a string
Right() grabs text from the right of a string
Mid() grabs text from the middle of a string
InStr() returns the position of a character in a string

EX:

Left("abc-xyz", 3) - returns "abc"
Right("abc-xyz", 3) - returns "xyz"
Mid("abc-xyz", 2, 2) - returns "bc"
InStr(1, "abc-xyz", "-") - returns 4
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com


Nov 13 '07 #4
"Rick Brandt" <ri*********@hotmail.comwrote in
news:aH*******************@newssvr14.news.prodigy. net:
Stinky Pete wrote:
>Arvo,

I've been reading about the above function, or similar, as it seems
applicable to my problem, however I have to admit I am totally lost.
What I need to do is update about 330 records that are currently in
the format "abc-xyz", all currently in a field called Type. I would
like to keep the "abc" text in the Type field and move/cut the "xyz"
text into a Description field. I only need to update the date once,
validate it is OK and then forget I ever did it ;-)

I think I'm making this harder than needed.

Regards,

Stinky Pete ;-)

Trim functions are about removing leading and trailing spaces and have
nothing to do with your issue. Look at the help file for descriptions
of the functions...

Left() grabs text from the left of a string
Right() grabs text from the right of a string
Mid() grabs text from the middle of a string
InStr() returns the position of a character in a string

EX:

Left("abc-xyz", 3) - returns "abc"
Right("abc-xyz", 3) - returns "xyz"
Mid("abc-xyz", 2, 2) - returns "bc"
InStr(1, "abc-xyz", "-") - returns 4
One brave, or foolish??? way to ltrim(,3) in SQL is to set the size of the
field to three.

In fooling with this, I learned something today:

using Northwind ...

Sub temp()
With DBEngine(0)(0)
On Error Resume Next
.Execute "ALTER TABLE Employees DROP Temp"
On Error GoTo 0
.Execute "ALTER TABLE Employees ADD Temp Text (50)"
.Execute "UPDATE EMPLOYEES Set Temp = LastName"
.Execute "ALTER TABLE EMPLOYEES ALTER TEMP Text (3)", dbFailOnError
End With
End Sub

Everything works with DAO.

Sub temp2()
With CurrentProject.Connection
On Error Resume Next
.Execute "ALTER TABLE Employees DROP Temp"
On Error GoTo 0
.Execute "ALTER TABLE Employees ADD Temp Text (50)"
.Execute "UPDATE EMPLOYEES Set Temp = LastName"
.Execute "ALTER TABLE EMPLOYEES ALTER TEMP Text (3)"
End With
End Sub

Not so with ADO.
The last sql "ALTER TABLE EMPLOYEES ALTER TEMP Text (3)"
fails returning a "field too small ..." error description.

I expect this is an argument for something, but I'm not sure what. I
suppose it depends upon whether you think the last SQL should run without
error.
--
lyle fairfield
Nov 13 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Shailesh Humbad | last post by:
I compiled this article on trim functions for Javascript: Javascript Trim LTrim and RTrim Functions http://www.somacon.com/p355.php If you have any comments, please let me know. Thanks,...
12
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I trim whitespace - LTRIM/RTRIM/TRIM?...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
agi2029
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 project—planning, coding, testing,...
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.