Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

finding VbCrLF in a table 1

Status
Not open for further replies.

gusset

Technical User
Mar 19, 2002
251
GB
some of my rows have carriage returns in them, which i'd like to get rid of.

do you know how i can replace them with an empty string?

thanks

gusset
 
just to clarify, i am using access 97. word's find/replace function is quite sophisticated and finds line feeds (^l), whereas access's doesn't.

i was able to solve the problem by exporting the table to word, writing down the primary keys of the rows and then deleting the s from the table in access based on the primary keys - a bit cumbersome.

i would have written some vba to do it, but couldn't be bothered writing a replace function, which did not appear before vba6.

any ideas for the future, please?

thanks

gusset
 
I take it that you're under the impression that the Replace function is some rather complicated function. It is not. In fact, you can do it in about 5 lines of code, or more efficiently in closer to 8 lines, by pre-computing the length of the string that is being replaced.

Two ideas for the future would be to write your own replace function. Someone will probably post it for you, but you wouldn't really learn anything from that. All you need is the Mid and Instr function, although the Left function could be used in place of one of the two Mid function calls.

If you're really not comfortable with that, I suggest that you take a look at the .Replace method of the Regular Expression object.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
thanks, i have written this function a few times before... but i'm aware that intrinsic functions work much faster than anything we can write.

i was just surprised that there is no way to do it through the interface...

good idea about regexp - i have been meaning to look at this!

thanks again

gusset
 
That's quite true, that intrinsic function will generally work faster that than which we write, but surely even a hand written Replace would've been faster than the Word based conversion, or maybe I'm under the impression that such a conversion is more cumbersome that it actually is.

The RegExp Replace is actually faster then than the VB6 intrinsic Replace function when dealing with larger strings, with multiple replacements.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
useful stuff, thanks.

gusset
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top