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

Replace function in Access

Hi

I have a website that uses an Access 2003 database. I have controls on
my pages that are bound to SqlDataSources that pull data from this
database. In a couple of them, I need to use the replace function to
replace some text in the results. Access' REPLACE function is only
available if executed within the environment, as it's a VBA function,
not a SQL function. So how can I implement this is the EASIEST
possible way? I don't to rewrite all my pages to first pull the data
into a DataSet and then do the replace, as I'll soon be back on SQL
Server, and can use the Replace function there.

Can I either do some sort of post-result transformation on the page
side, or how do I set up a macro / function in Access that the query
will be able to see? I created a MYREPLACE function in a Module, which
works fine if I run it in Access, but I still get the web error:
System.Data.OleDb.OleDbException: Undefined function 'MYREPLACE' in
expression

thanks
Sean
Jun 27 '08 #1
1 4610
<se**************@hotmail.comwrote in message
news:43**********************************@m3g2000h sc.googlegroups.com...
I have a website that uses an Access 2003 database.
Firstly, you don't. There is, strictly speaking, no such thing as an Access
2003 database. In fact, there's no such thing as an Access database of any
kind. Microsoft Access is a database application development tool, not a
database. Microsoft Access uses the Jet database natively, as do several
other Microsoft applications:
http://en.wikipedia.org/wiki/Microso...atabase_Engine

You may think this is extremely pedantic because I, and everyone else in
here, know perfectly well what you mean when you talk about an Access
database, but it's fundamental to the understanding of the problem you're
currently facing.
In a couple of them, I need to use the replace function to
replace some text in the results. Access' REPLACE function is only
available if executed within the environment, as it's a VBA function,
not a SQL function.
You are completely correct. Microsoft Access or, more correctly, the VBA
included with Microsoft Access, does indeed have a Replace() function. The
problem is, as you've discovered, is that you're not using Microsoft
Access - you're using a Jet database via ADO.NET - so none of the useful
time-saving stuff for which Access is so useful is available to you...
So how can I implement this is the EASIEST possible way?
I don't [want] to rewrite all my pages to first pull the data
into a DataSet and then do the replace, as I'll soon be back on SQL
Server, and can use the Replace function there.
OK.
Can I either do some sort of post-result transformation on the page
side, or how do I set up a macro / function in Access that the query
will be able to see? I created a MYREPLACE function in a Module, which
works fine if I run it in Access, but I still get the web error:
System.Data.OleDb.OleDbException: Undefined function 'MYREPLACE' in
expression
That would be correct. Forget Microsoft Access completely, as you're not
using Microsoft Access.

Luckily, there is (probably) an extremely simple way round this.

You say that you are using databound controls. I'm assuming that you mean
webcontrols such as <asp:GridView /etc.

If so, then you can do what you want extremely simply by using the
RowDataBound event:
http://msdn.microsoft.com/en-us/libr...databound.aspx

This will allow you to write code which will inspect every row of data just
before it gets bound to the control, and will allow you to do any
manipulation of that data which you require.

Other databound webcontrols have similar functionality...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #2

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

Similar topics

2
by: Daniel | last post by:
I use an Access database to basically take data exports, import them, manipulate the data, and then turn them into exportable reports. I do this using numerous macros, and queries to get the data...
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: asd987 | last post by:
Hi, Can anyone tell me if "replace" is supported by Access 97? I use the Dutch version and get the errormessage "sub or function not supported". Or is the Professional Edition needed? Thanks.
3
by: Dave | last post by:
I have an Access 2K application that is distributed to about a dozen users (all with identical NT environments and identical Access versions, object libraries and service packs). I am using the VBA...
5
by: galsaba | last post by:
I just found out that Replace Function exists in Access XP (as part of MS Office), but does not exist in Access 2000 (as part of access 2000). Any idea how I can resolve it? Does access 2000 has an...
2
by: Ermi | last post by:
Hi, i have this problem.... From a visual basic application I must replace the value contained in a column with another one....for example Field1 ------ Alfa Beta Gamma
3
by: mal_lori | last post by:
Hello, I have an ongoing problem with a single machine not recognizing the REPLACE function. This is a WinXP Pro machine, running Office 2000 (SP3) with MDAC 2.8 (SR1) and Jet 4 installed. ...
4
by: Lauren Wilson | last post by:
Hi folks, We have a need to replace sub strings in certain message text. We use the Office Assistant to display help and often use the imbedded formatting commands. Those of you who have used...
1
by: seanmatthewwalsh | last post by:
Hi I have a website that uses an Access 2003 database. I have controls on my pages that are bound to SqlDataSources that pull data from this database. In a couple of them, I need to use the...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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,...

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.