Indicate a textbox is overflowing

G

Guest

I have some textboxes on a form that are of a certain size. Sometimes there
is more text than will fit in these boxes. I have found where you can change
the Scroll Bar property for the text box to 'Vertical' but the scroll bars
only show if the user clicks in the textbox. So if the user never happens to
click in the box he might not know that there was more text there. My
question is, How can I indicate that there is more text in a box than what is
showing? I would be okay with resizing the textbox to fit the amount of text
but how can you do that without messing up the forms layout? As always,
thanks to everyone in these forums who helps out.
 
G

George Nicholson

One approach:
In the OnCurrent event, check the length of the textbox field
if over x, change the background color of the control to something
meaningful
else use the default background (necessary to set the color "back")

HTH,
 
J

John W. Vinson

I have some textboxes on a form that are of a certain size. Sometimes there
is more text than will fit in these boxes. I have found where you can change
the Scroll Bar property for the text box to 'Vertical' but the scroll bars
only show if the user clicks in the textbox. So if the user never happens to
click in the box he might not know that there was more text there. My
question is, How can I indicate that there is more text in a box than what is
showing? I would be okay with resizing the textbox to fit the amount of text
but how can you do that without messing up the forms layout? As always,
thanks to everyone in these forums who helps out.

George's suggestion is a good one... but bear in mind that it can be
remarkably difficult to determine if a textbox is full or not! Most fonts are
proportional, so the number of characters that will fit in a textbox is
variable; you can put a lot more "lllll" than you can "MMMMM". I would guess
the indomitable Stephen Lebans has some code that will check the control's
font settings, but I've never figured out how to do so.

A fixed-pitch font such as Courier New will be one (possibly somewhat ugly)
solution.

John W. Vinson [MVP]
 
P

Peter Hibbs

Steven.

If the users are moving to a new line by pressing the ENTER key you
could check for the presence of the CR character in the text string
which would indicate that there is more than one line.

You could also use Conditional Formatting to check this (providing you
are using A2000 or later). To do this set the first field in the
Conditonal Formatting form to :- Expression Is and the second
field to :- InStr([Notes],Chr(13))<>0 and set the appropriate
background colour as required.

HTH

Peter Hibbs.
 
G

Guest

Thanks again to all. I understand what you are saying but I'm not sure I can
see how to apply it. I can certainly count the number of characters or I
could count the number of Returns to determine the number of lines. But 200
characters might be 3 lines or it might be 20 lines. I guess if the number of
charters is greater than X and the number of returns is greater than Y there
has to be an overflow situation. I'll have to think about it....

I was hoping that there was a Property I was not aware of such that 'If
textbox OVERFLOW = True'. Why hasn't Microsoft written that yet!! ;-)

Peter Hibbs said:
Steven.

If the users are moving to a new line by pressing the ENTER key you
could check for the presence of the CR character in the text string
which would indicate that there is more than one line.

You could also use Conditional Formatting to check this (providing you
are using A2000 or later). To do this set the first field in the
Conditonal Formatting form to :- Expression Is and the second
field to :- InStr([Notes],Chr(13))<>0 and set the appropriate
background colour as required.

HTH

Peter Hibbs.

I have some textboxes on a form that are of a certain size. Sometimes there
is more text than will fit in these boxes. I have found where you can change
the Scroll Bar property for the text box to 'Vertical' but the scroll bars
only show if the user clicks in the textbox. So if the user never happens to
click in the box he might not know that there was more text there. My
question is, How can I indicate that there is more text in a box than what is
showing? I would be okay with resizing the textbox to fit the amount of text
but how can you do that without messing up the forms layout? As always,
thanks to everyone in these forums who helps out.
 
S

Stephen Lebans

The closest you can some to your desired solution is here:

http://www.lebans.com/textwidth-height.htm
TextHeightWidth.zip is a replacement for the Report object's TextWidth and
TextHeight methods. It is multiline aware and can work in both Report and
Form views. Includes a sample report to show you how to autosize individual
controls with different formatting on the same line to simulate RTF style
text.


--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


Steven Sutton said:
Thanks again to all. I understand what you are saying but I'm not sure I
can
see how to apply it. I can certainly count the number of characters or I
could count the number of Returns to determine the number of lines. But
200
characters might be 3 lines or it might be 20 lines. I guess if the number
of
charters is greater than X and the number of returns is greater than Y
there
has to be an overflow situation. I'll have to think about it....

I was hoping that there was a Property I was not aware of such that 'If
textbox OVERFLOW = True'. Why hasn't Microsoft written that yet!! ;-)

Peter Hibbs said:
Steven.

If the users are moving to a new line by pressing the ENTER key you
could check for the presence of the CR character in the text string
which would indicate that there is more than one line.

You could also use Conditional Formatting to check this (providing you
are using A2000 or later). To do this set the first field in the
Conditonal Formatting form to :- Expression Is and the second
field to :- InStr([Notes],Chr(13))<>0 and set the appropriate
background colour as required.

HTH

Peter Hibbs.

I have some textboxes on a form that are of a certain size. Sometimes
there
is more text than will fit in these boxes. I have found where you can
change
the Scroll Bar property for the text box to 'Vertical' but the scroll
bars
only show if the user clicks in the textbox. So if the user never
happens to
click in the box he might not know that there was more text there. My
question is, How can I indicate that there is more text in a box than
what is
showing? I would be okay with resizing the textbox to fit the amount of
text
but how can you do that without messing up the forms layout? As always,
thanks to everyone in these forums who helps out.
 
P

Peter Hibbs

Steven.

I believe you can still use Conditional Formatting to do what you
want. I assume you have one or more text boxes on a form that
currently show a set number of lines of text and you want to have some
way of indicating to the user that there are more lines of text stored
than are currently visible.

What you can do is create a Code Module (if you haven't already got
one) and paste the following function into it :-


Public Function CountCR(vFieldName As String) As Long

Dim vPosn As Long

For vPosn = 1 To Len(vFieldName)
If Mid(vFieldName, vPosn, 1) = vbCr Then
CountCR = CountCR + 1
End If
Next

End Function

Then in the Conditional Formatting form for each text box, enter this
line in the second box (set the first to Expression Is) -

CountCR([YourTextBoxName])>2

Where 'YourTextBoxName' is the name of your text box and the last
digit is the number of visible lines in your text minus one (this
would be for 3 lines of text). You can also use SHIFT + F2 to display
the full text box.

HTH

Peter Hibbs.

Thanks again to all. I understand what you are saying but I'm not sure I can
see how to apply it. I can certainly count the number of characters or I
could count the number of Returns to determine the number of lines. But 200
characters might be 3 lines or it might be 20 lines. I guess if the number of
charters is greater than X and the number of returns is greater than Y there
has to be an overflow situation. I'll have to think about it....

I was hoping that there was a Property I was not aware of such that 'If
textbox OVERFLOW = True'. Why hasn't Microsoft written that yet!! ;-)

Peter Hibbs said:
Steven.

If the users are moving to a new line by pressing the ENTER key you
could check for the presence of the CR character in the text string
which would indicate that there is more than one line.

You could also use Conditional Formatting to check this (providing you
are using A2000 or later). To do this set the first field in the
Conditonal Formatting form to :- Expression Is and the second
field to :- InStr([Notes],Chr(13))<>0 and set the appropriate
background colour as required.

HTH

Peter Hibbs.

I have some textboxes on a form that are of a certain size. Sometimes there
is more text than will fit in these boxes. I have found where you can change
the Scroll Bar property for the text box to 'Vertical' but the scroll bars
only show if the user clicks in the textbox. So if the user never happens to
click in the box he might not know that there was more text there. My
question is, How can I indicate that there is more text in a box than what is
showing? I would be okay with resizing the textbox to fit the amount of text
but how can you do that without messing up the forms layout? As always,
thanks to everyone in these forums who helps out.
 
G

Guest

Thanks Peter for the code snippet. Now all I have to do is figure out what it
does! ;-)

And as often as I have seen the name Stephan Lebans show up in these forums
I should have known you would already have addressed an issue like this one.
Next time after searching these forums for an answer and not finding it, I
should probably check your website.

Thanks to both of you.
 
P

Peter Hibbs

Steven

If you have any problems just post back, I or someone else will be
able to help.

Also, I don't have my own Web site, I use a part of Roger Carlson's
excellent site at :-
http://www.rogersaccesslibrary.com/OtherLibraries.asp
which has a lot of useful tips and code.

And Stephen Lebans has a brain the size of a planet, I don't pretend
to know a fraction of what he knows about Access.

Peter Hibbs.
 
J

John W. Vinson

And Stephen Lebans has a brain the size of a planet, I don't pretend
to know a fraction of what he knows about Access.

<chuckle>

I don't think there's anyone, inside or outside of Microsoft, who knows as
much about Access as Stephen.


John W. Vinson [MVP]
 
F

Fred Boer

And Stephen Lebans has a brain the size of a planet, I

True, but he uses a clever compression algorithm of his own devising so that
his head is actually a reasonable size...

Fred Boer
 

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