473,397 Members | 2,056 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,397 software developers and data experts.

Help using REPLACE in a query

Hi - I am a newbie to Access & SQL and I would appreciate some help on
this if at all possible.

I have a query that contains the following code.

SELECT DISTINCT Product.[Short description] AS [Product Name],
Product.[Full description] AS [Product Description] ;

The problem I have is that the Product.[Full description] contains
characters that I do not want displayed in the query but are required
in the database. Therefore I want to replace !!<<ul>, <li> and
</ul>>!! with nulls and replace </li> with a full stop (period) in the
query.

I believe that this cannot be done directly in access but requires a
function to be created.

Can anyone point me in the right direction?
Nov 12 '05 #1
8 19967
As I understand it, you can use REPLACE in a query in Access 2002 or 2003.

If you're using an earlier version, post back for more...
- Turtle
"skinnybloke" <th**************@yahoo.co.uk> wrote in message
news:qg********************************@4ax.com...
Hi - I am a newbie to Access & SQL and I would appreciate some help on
this if at all possible.

I have a query that contains the following code.

SELECT DISTINCT Product.[Short description] AS [Product Name],
Product.[Full description] AS [Product Description] ;

The problem I have is that the Product.[Full description] contains
characters that I do not want displayed in the query but are required
in the database. Therefore I want to replace !!<<ul>, <li> and
</ul>>!! with nulls and replace </li> with a full stop (period) in the
query.

I believe that this cannot be done directly in access but requires a
function to be created.

Can anyone point me in the right direction?

Nov 12 '05 #2
Hi - MS Access 2000 I'm afraid.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #3
Yes, it does, but in earlier versions (i.e.: if all the service packs
haven't been installed), you can't use the VBA Replace function in a query
in Access 2000.

Fortunately, there's a trivial work-around.

Write your own shell to use the VBA Replace function, and use your shell in
the query, rather than Replace.

Function MyReplace(Expression As String, Find As String, Replace As String)
MyReplace = Replace(Expression, Find, Replace)
End Function

You then use MyReplace in the query.
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(No private e-mails, please)

"Chuck Grimsby" <c.*******@worldnet.att.net.invalid> wrote in message
news:qf********************************@4ax.com...

Access 2K has the Replace Function as well.

On 26 Apr 2004 12:27:13 GMT, skinnybloke
<th**************@yahoo.co.uk> wrote:
Hi - MS Access 2000 I'm afraid.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #4
hi - thanks for the replies. I have got all of the service packs
installed so I can use replace - I tried this successfully for a single
string but I am totally clueless on how to do this for multiple strings
as per my original post.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #5
rkc

"skinnybloke" <th**************@yahoo.co.uk> wrote in message
news:40*********************@news.frii.net...
hi - thanks for the replies. I have got all of the service packs
installed so I can use replace - I tried this successfully for a single
string but I am totally clueless on how to do this for multiple strings
as per my original post.

As Douglas J. Steele suggested and you quessed in your original post
you need to write your own function. Only in your case you need the
function to use the Replace function multiple times in one call.

Something like:

Function FixDescription ( s as string) as string
s = replace(s, "<li>", "")
s = replace(s, "<ul>", "")
s = replace(s, "<\ul>", "")
s = replace(s, "<\li>", ".")

FixDescription = s
End Function

Nov 12 '05 #6
skinnybloke <th**************@yahoo.co.uk> wrote in news:408e37ca$0$205
$7*******@news.frii.net:
hi - thanks for the replies. I have got all of the service packs
installed so I can use replace - I tried this successfully for a single
string but I am totally clueless on how to do this for multiple strings
as per my original post.


A quick scan of the web did not produce any solution for this, (but there
might be many good ones I overlooked).

So, with morning coffee, why not try to write one:

Her's my first try, tested on a whole two pieces of HTML.

Public Function StripHTMLTags( _
ByVal HTML As String) As String
Dim a() As String
Dim v As Variant
a() = Split(HTML, "<")
For Each v In a
StripHTMLTags = StripHTMLTags & Mid$(v, InStr(v, ">") + 1)
Next v
End Function

What's yours, or how would you improve mine?

--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Nov 12 '05 #7
Hi - excellent stuff.

Just to take this one place further, how would this function need to
be modified to remove tags and the text between matching sets of html
tags.

e.g. <p>text text text</p>

remove the lot?

On 27 Apr 2004 11:16:41 GMT, Lyle Fairfield
<Mi************@Invalid.Com> wrote:
skinnybloke <th**************@yahoo.co.uk> wrote in news:408e37ca$0$205
$7*******@news.frii.net:
hi - thanks for the replies. I have got all of the service packs
installed so I can use replace - I tried this successfully for a single
string but I am totally clueless on how to do this for multiple strings
as per my original post.


A quick scan of the web did not produce any solution for this, (but there
might be many good ones I overlooked).

So, with morning coffee, why not try to write one:

Her's my first try, tested on a whole two pieces of HTML.

Public Function StripHTMLTags( _
ByVal HTML As String) As String
Dim a() As String
Dim v As Variant
a() = Split(HTML, "<")
For Each v In a
StripHTMLTags = StripHTMLTags & Mid$(v, InStr(v, ">") + 1)
Next v
End Function

What's yours, or how would you improve mine?


Nov 12 '05 #8
skinnybloke <th**************@yahoo.co.uk> wrote in
news:70********************************@4ax.com:
Hi - excellent stuff.

Just to take this one place further, how would this function need to
be modified to remove tags and the text between matching sets of html
tags.

e.g. <p>text text text</p>

remove the lot?


Probably, I would start considering the problem anew, without necessarily
basing any solution on the function in question.

--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Nov 12 '05 #9

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

Similar topics

1
by: Barnes | last post by:
I have an asp form that sends data to a redirect page with SQL using JScript. There is a function that I'm using called replace(). The form submits without errors and goes to the redirect page but...
6
by: J Smith | last post by:
After doing some googling through the lists and such, I wasn't able to arrive at a solution for a problem I've run into recently. I've seen mention of similar symptoms, but my case seems different....
12
by: Amanda | last post by:
I have tried everything with this! I get an error stating "Index was outside the bounds of the array" My code looks like this.... xmlDoc = New XmlDocument() xmlDoc.Load("xml.doc") xslDoc...
8
by: skinnybloke | last post by:
Hi - I am a newbie to Access & SQL and I would appreciate some help on this if at all possible. I have a query that contains the following code. SELECT DISTINCT Product. AS , Product. AS ; ...
3
by: mailto.anand.hariharan | last post by:
Hello group. This is my first message in this group, and my first stab at Javascript. I am trying to tweak the code for the "FOLDOC button" (http://foldoc.org/foldoc/tools.html) to be able to...
4
by: feucos | last post by:
Hi all, I am new to these so plz never mind if this is funny. here is my problem : Table : moody Column : Title
6
by: JackpipE | last post by:
Here is my replace query and I need to run this on every column in my table. Right now I manually enter the column name (_LANGUAGES_SPOKEN) but this is time consuming and would like to automate...
13
by: Jennifer.Berube | last post by:
well I'm not sure how to go about making my SQL connection string... The code below is what I need to replace with my SQL connection...I just don't know if that code is for DSN or access... I...
4
by: pankajsingh5k | last post by:
Hi guys, These question is for all the experts... Please help me before my brain explodes The problem is again with the formview control.. I have a formview and i have to use it that...
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:
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
tracyyun
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...
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.