473,386 Members | 1,753 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,386 software developers and data experts.

Find/replace in an access table via macro/vb

Hi,

I need a macro to replace all incidents of a carriage return in one field in an Access table with spaces. It's a table that gets reimported into a database repeatedly, and there are always unwanted carriage returns in the imported fields.

How can I do this within VB?

Jon
Aug 7 '07 #1
5 10406
FishVal
2,653 Expert 2GB
Hi,

I need a macro to replace all incidents of a carriage return in one field in an Access table with spaces. It's a table that gets reimported into a database repeatedly, and there are always unwanted carriage returns in the imported fields.

How can I do this within VB?

Jon
Hi, Jon.

All what you need is to design Update query and run it manually or from VBA code (DoCmd.OpenQuery ...)
Aug 7 '07 #2
nico5038
3,080 Expert 2GB
Personally I use a Replace() function.
As the older Access versions don't support this in a query, but do support userdefined functions (from the modules section), I tend to use this simple function:

Expand|Select|Wrap|Line Numbers
  1. function fncReplace(strInput as String) as String
  2.  
  3. ' Replace the single LF (linefeed) with the DOS CRLF (CarriageReturn + LineFeed)
  4. fncReplace = Replace(strInput,chr(10),chr(13)&chr(10))
  5.  
  6. end function
  7.  
Now in an Update query use:
Expand|Select|Wrap|Line Numbers
  1. UPDATE tblX Set FieldText = fncReplace(FieldText)
  2.  
Getting the idea?
Ofcource the Replace "from" and "to" parameters, being chr(10) and chr(13)&chr(10) can be replaced with any value needed.

Nic;o)
Aug 7 '07 #3
Hi Nic,

Thanks very much for the contribution. I'll check it out and tell you how far I get!

Jon
Aug 13 '07 #4
It works a treat. I'm learning loads about Access and VB on this forum. Thanks very much. I hope to be able to help others more in future!
Aug 13 '07 #5
nico5038
3,080 Expert 2GB
Glad I could help :-)

Success with your application and be sure that helping others also teaches you a lot !

Nic;o)
Aug 13 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Fred | last post by:
Hi. How do I import while mapping an excel table to an access table please??? I've searched around and all I can find is a software product or code that does the same thing as the access...
1
by: Rob Korsten | last post by:
I want to import frequently an excel format file in an access table. Is it possible to do this with a macro/module (VBA ?). I think it is for daily use more easy than with the standard import...
2
by: SenseForAll | last post by:
First please note I am a novice at VBA and not even that experienced with DAO/ADO and MS-SQL. Any assistance is appreciated. That said... I have an application written in Access w/ VBA. I need to...
1
by: Pierre Maricq | last post by:
Hi, I am using Win2000 and Access2000. I need to build build a macro or write a VBA in Access that would screen all files contained in a directory on my C drive (files are structrured DAT...
0
by: hartliec | last post by:
I would like to execute a Access 2002 Macro (TransferText) using ASP. Any ideas? This is what I have so far.. Page 1 *****accessmacro.asp************ <html><body> <% strDbName = 'Put...
1
by: Lengara | last post by:
I have an Access form that will be FTPing information. The FTP info will be using a text file located on the hard drive. This text file will have symbolics in it that will be replaced by entries on...
2
by: loneranger | last post by:
Hi Everyone Visual Studio 2005 VB 2005 Windows Application I have a form with one combo box and a button I want the user to make a selection from the combo box, click the button and have...
2
by: koupolga | last post by:
Hello! Im trying to do something with my database and Im not even sure if its possible. I have a finished database with about 30 queries all updating the same table. I would like to make an exact...
4
by: Elliot Fraval | last post by:
Hi All, Environment is VBA code in Access 2007. I am having some problems performing a find and replace on text that originates from a memo field in a table. The code is supposed to take...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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,...
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...

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.