[AccessD] How to Change CRCRLF to just CRLF

William Benson vbacreations at gmail.com
Fri Aug 2 19:11:31 CDT 2013


Latter is safest.

Always better to replace the most  narrowly defined string, even if it
means something that to a mathematician would seem redundant.

I would also say that it might be beneficial to find out the source of the
data anomaly, it seems ominous.

Not only that, I have seen some data which belongs all in one field,
contain such line break type characters, and performing such global
replaces is not the way to go in such cases.

I think I would test the data row by row, and if this anomaly is occurring
only at the end of a line, break said line into two parts, the 2nd par
being tje last 3 characters, and the 1st being everything to the left of
that. Then recombine using the replace statement already described, but
operated only upon the 2nd partial. That will avert any risk of changing
something that should not have been changed.

Always try to do the least change via Replace$ as required in a single step.
On Aug 1, 2013 7:24 PM, "John Bodin" <jbodin at sbor.com> wrote:

> Brad, you could do either replace(Str_A, chr(13) & chr(13), chr(13)) or
> replace(Str_A, chr(13) & chr(13) & chr(10), chr(13) & chr(10))
>
> Or use the constant vbCrLf for a little better readability.
>
> John
>
> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com [mailto:
> accessd-bounces at databaseadvisors.com] On Behalf Of Steve Schapel
> Sent: Thursday, August 01, 2013 6:19 PM
> To: Access Developers discussion and problem solving
> Subject: Re: [AccessD] How to Change CRCRLF to just CRLF
>
> Hi Brad
>
> Does this work?...
>
> Str_A = Replace(Str_A, Chr(13) & Chr(13) & Chr(10), Chr(13) & Chr(10))
>
> Regards
> Steve
>
> -----Original Message-----
> From: Brad Marks
> Sent: Friday, August 02, 2013 9:53 AM
> To: Access Developers discussion and problem solving
> Subject: [AccessD] How to Change CRCRLF to just CRLF
>
> All,
>
> We have an Access-based system that pulls records via ODBC from a
> purchased Accounting system in order to generate EDI transactions.
>
> For over three years, everything has worked nicely.
>
> Today, one of the generated EDI transactions failed.  In looking at the
> records pulled from the Accounting system, it appears that a small number
> of the records end with CRCRLF instead of just CRLF (Carriage Return Line
> Feed).
>
> I can change the CR (Hex od) to spaces with a replace command like this
>
> Str_A = Replace(Str_A, Chr(13), " ")
>
>
> However, I don't want to replace all CRs with spaces.  I only want to
> replace the first CR with spaces when I find CRCRLF.
>
> Is there a way to do this with VBA?
>
> Thanks,
> Brad
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>


More information about the AccessD mailing list