Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / July 2007

Tip: Looking for answers? Try searching our database.

Replace function

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
EMILYTAN - 17 Jul 2007 01:10 GMT
Is there any way to delete a string out of many string under the same column?
For example:-

In a serial number column consists of MY111, MY 123, MY456
If user specify to delete MY456, it will delete MY456 while retaining the
value of MY111, MY123 using update statement?

How am I suppose to use replace function..?

For example:-

mySQL7 = "UPDATE WIPRawDetails replace([SerialNumber]'" & strSerialNumber1 &
"',"")WHERE JobNumber= '" & Me.txtJobNumber & "' and PartNumber = '" &
strPartNumber & "'"
DoCmd.RunSQL mySQL7
John W. Vinson - 17 Jul 2007 07:08 GMT
>Is there any way to delete a string out of many string under the same column?
>For example:-
>
>In a serial number column consists of MY111, MY 123, MY456
>If user specify to delete MY456, it will delete MY456 while retaining the
>value of MY111, MY123 using update statement?

You're storing *three serial numbers* in one field? That is a rather bad idea!
The problem you're having is just one reason why it's a bad idea.

>How am I suppose to use replace function..?
>
[quoted text clipped - 4 lines]
>strPartNumber & "'"
>DoCmd.RunSQL mySQL7

You can use

mySQL7 = "UPDATE WIPRawDetails SET [SerialNumber] =
Replace([SerialNumber] & ",", """ & strSerialNumber1 & ",""")
WHERE JobNumber= '" & Me.txtJobNumber & "' and PartNumber = '" &
strPartNumber & "'"

This assumes that the job number and part number criterion reliably identifies
the records to be fixed. I'm appending a comma to the end of the string in
case strSerialNumber1 comes last in the string - which would cause it to be
missed in the replace.

You would REALLY REALLY be *much* better off normalizing your tables, rather
than storing multiple values in one field!!!

            John W. Vinson [MVP]
EMILYTAN - 17 Jul 2007 07:45 GMT
Ya...thanks for your advice....
I have think twice..it is not good to do it..So, I decide not to do..
But since you have given me the solution, I will learn on the replace
function as well...
Thanks
>>Is there any way to delete a string out of many string under the same column?
>>For example:-
[quoted text clipped - 28 lines]
>
>             John W. Vinson [MVP]
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.