validation rules avoid line brake

D

davidg

Hello
I would like to avoid line brake in fileds by using validation rules.
All other characters should be valid

How can I do that?
 
D

davidg

Hello Bonnie

Yes I think it might be the CHR(13) or CHR(10).
They get in by copy and pasting.
 
D

Douglas J. Steele

Why not just use the Replace function to remove those characters from the
input before storing the data?
 
D

davidg

if a line brake is entered also the characters after the line brake might be
wrong.
Therefore records with line brake should not be allowed.
 
K

Klatuu

You could use

Instr([MyField], Chr(13) & Chr(10)) = 0

Would mean the field has no line break.
 
D

davidg

Hello Klatuu

Thanks a lot. I think that might be the way to go but still it works not as
I hope.
with the new validation rule Instr([MyField]; Chr(13) & Chr(10)) = 0

It will not accept an empty field, which was emptied by the user.
(If befor an invalid value was in the file and no the filed has been
emptied, than the rule prevents an empty field.





Klatuu said:
You could use

Instr([MyField], Chr(13) & Chr(10)) = 0

Would mean the field has no line break.

davidg said:
if a line brake is entered also the characters after the line brake might
be
wrong.
Therefore records with line brake should not be allowed.
 
J

John W. Vinson

Hello Klatuu

Thanks a lot. I think that might be the way to go but still it works not as
I hope.
with the new validation rule Instr([MyField]; Chr(13) & Chr(10)) = 0

It will not accept an empty field, which was emptied by the user.
(If befor an invalid value was in the file and no the filed has been
emptied, than the rule prevents an empty field.

If you want to exclude newlines in a validation rule, I'd suggest

NOT LIKE "*" & Chr(13) & Chr(10) & "*"
 
D

davidg

Hello John

no luck! Not Like "*" & Chr(13) & Chr(10) & "*" is not working, also when I
use only one of the chr(XX).

When I delete the content of the field I receive the message that I enter a
vaule which does not meet the validation rule.

I also tried to add Not Like "*" & Chr(13) & Chr(10) & "*" or like ""

but even that is not working

Do I have to change other properties of the field?
 
J

John W. Vinson

Hello John

no luck! Not Like "*" & Chr(13) & Chr(10) & "*" is not working, also when I
use only one of the chr(XX).

When I delete the content of the field I receive the message that I enter a
vaule which does not meet the validation rule.

I also tried to add Not Like "*" & Chr(13) & Chr(10) & "*" or like ""

but even that is not working

Do I have to change other properties of the field?

Sorry! If it's ok for the field to be empty you need a validation rule such as

Not Like "*" & Chr(13) & Chr(10) & "*" OR IS NULL
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Validation Rules for a Control on a Form (?) 4
Page Break 3
Validation Rule assistance 0
Validation Rule Error Messages 1
Line brake in a MsgBox 2
Validation Rule Popup 1
Validation Rule 3
Validation in child form 1

Top