tags:

views:

2138

answers:

2

A simple question, doing my head in...

I have a large access database to clean up.

Is there a system constant for a line break in Access (Like VB's VBCrLf)?

If not,I guess I'll just have to use Chr(13) + Chr(10)

+5  A: 

In VBA, vbCrLf is the line break constant (along with vbCr and vbLf).

In a string data column, it's Chr(13) + Chr(10) (which is what vbCrLf is defined as).

Mitch Wheat
+1  A: 

While vbCrLf, vbCr and vbLf exist, it is better to use vbNewLine.

Why?
1) Because vbNewLine will output the newline sequence for the current operating system (which may change) vs the other three which will put out only the carriage return and linefeed characters.
2) Because it is less cryptic. Using vbCr is just about as bad as chr(13)

The logical comeback is... come on when is MS ever going to change the newline, they'd be nuts. As it is, portability. There are already .Net ports to unix/linux and there is no reason that MS access can't be emulated there either. (E.g., perhaps in Wine)

Edit

A parallel to this idea would be using \n in C and C++ vs entering \f\r. \n will give you the native newline sequence (even if you flip from Unix to Windows to Mac to Vax to QNX). No conditional statements, no edits. It just works.

CodeSlave
What, exactly, does .NET have to do with Access? I have to say, I think your suggestion is crazy. :)
David-W-Fenton
.Net is just a parallel example. I presume that you might be able to run a MS access app in Wine (no idea, but the philosophy is the same).
CodeSlave
+1. This is a valid point. There is usually no good reason to not code for optimal portability -- now or in the future.
Adam Bernier