Prohibit Down Arrow Scroll in Textbox

W

wrldruler

I have a textbox of a particular size. This size matches the size of
the box on a report. If users write too much text, it will overflow
the report box. So they need to use only the room available in the
textbox.

I have disabled scrollbars on the textbox, as well as disabled Can
Grow and Can Shrink.

But the users are still able to type as much as they want. The textbox
still scrolls to the next line. They can still use the down arrow on
the keyboard to scroll down the textbox.

How can I create a textbox of a fixed hieght, that cannot scroll down
no matter what?

Thanks
 
R

rvanl

If the field is unbound, you still can use the validation Rule option
of the textbox to limit the # of characters as well with the len()
function
R
 
W

wrldruler

I've done character limits before, but it didn't completely solve the
problem. Someone can use line breaks, write only a couple words, but
still exceed the hieght of the box.

For instance:

* The project

* Is going

* Very Well

The above is only 34 characters, but 5 lines, and would likely fill
the box.

So is there a way to count lines instead?

Thanks
 
D

Douglas J. Steele

It takes two characters to represent a new line (Chr(13), which is a
carriage return and Chr(10), which is a line feed). You can determine the
number of lines using:

Len("text to check") - Len(Replace("text to check", Chr(13) & Chr(10),
""))/2

If you've got the text in a variable strText, that would be

Len(strText) - Len(Replace(strText, Chr(13) & Chr(10), ""))/2

If it's in text box Text0 and your code is in the module associated with
that form, it's

Len(Me.Text0) - Len(Replace(Me.Text0, Chr(13) & Chr(10), ""))/2

If your codes not in the module associated with the form, it's

Len(Forms!NameOfForm.Text0) - Len(Replace(Forms!NameOfForm.Text, Chr(13) &
Chr(10), ""))/2
 

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

Top