473,835 Members | 2,203 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 20009
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
"skinnyblok e" <th************ **@yahoo.co.uk> wrote in message
news:qg******** *************** *********@4ax.c om...
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(Expre ssion As String, Find As String, Replace As String)
MyReplace = Replace(Express ion, 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.*******@worl dnet.att.net.in valid> wrote in message
news:qf******** *************** *********@4ax.c om...

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

"skinnyblok e" <th************ **@yahoo.co.uk> wrote in message
news:40******** *************@n ews.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.c om:
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
1414
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 the data doesn't populate the SQL database. Instead, referrs to the last key ID. ------------------------ <% function replace(string) { var pattern = /\'/g; var newString = string.replace(pattern, "''"); // Create a database connection.
6
1998
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. After recently upgrading to 7.3.4 from 7.3.1, I started having problems with using subselects in INSERTs. I'm seeing things like this (simplified, as this is a part of a larger database): INSERT INTO t1 (name) VALUES ('foo'); INSERT 123 1
12
2148
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 = New XslTransform()
8
499
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 ; The problem I have is that the Product. contains characters that I do not want displayed in the query but are required
3
1464
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 execute a DB query over my firm's intra-net. The source code for the IE button is as follows:
4
23800
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
15597
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 this process as much as possible. Update PROFILE SET LANGUAGES_SPOKEN = replace(cast(_LANGUAGES_SPOKEN as nvarchar(255)),char(13)+char(10),':') Thanks,
13
2851
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 don't want to use DSN just a connection string...help? function GetConnection() const DSN = "membershipdb" const UID = "webuser"
4
8573
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 when it displays it shows values from the database and i have a link button edit on the ItemTemplate that changes the mode to edit mode and allows to edit the values which can be edited...
0
9810
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10815
Oralloy
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...
0
10526
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10563
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,...
0
10237
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 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...
0
9348
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, and deployment—without 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...
0
5640
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5808
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3094
bsmnconsultancy
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...

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.