If you are dealing with a very small data file, or this is
just a one-shot program than you can skip the rest of this
post with my apologies.
I stress again that you should really focus on correcting
the problem from the source and then generating an usable
export file. Important issues still hold true:
- What if the text that follows the hard return begins
with a number?
- What if two separate fields in the same record have
hard returns? (a three line record).
- Can you enumerate every possible scenario of this sort?
Here is MS Access VB code that will allow you to create a
global function that can be called anywhere from within
your application and strip the hard returns. It is
certainly not optimized, but I'm at work and had to do a
quick and dirty. Just be sure that you make a copy of your
Access database to work/export from. Create a MS
Access VB module:
Option Compare Database
Option Explicit
Public Function Strip_crlf(mStr)
Dim mNewStr As String
mNewStr = mStr
While (InStr(mNewStr, Chr(13)))
Mid(mNewStr, InStr(mNewStr, Chr(13)), 1) = " "
Wend
While (InStr(mNewStr, Chr(10)))
Mid(mNewStr, InStr(mNewStr, Chr(10)), 1) = " "
Wend
Strip_crlf = mNewStr
End Function
Once you create this module you can use the function to
either write a sub that will process all text fields in
the database, more simply create a Update Query that does
the module call:
Strip_crlf([fieldname]) for each "Update to:" text field. Then export the
table as you originally wanted it.
HTH,
--Jim
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.