Count lines in text box

G

Guest

Hello,

I made a database of Terms and Definitons (long ones) to study for biology
exams. I often print out these terms on 4x6 flashcards (via a report I
made), therefore, "txt4x6Display" represents perfectly the size of a 4x6
flashcard. However, some of the definitions run long, and therefore some of
the info doesn't appear on the card. I would like an unbound text box
(perhaps, txtLineCount) to display a count of the number of lines in
txt4x6Display. A previous post showed how to count the number of carriage
returns...however, I need to be able to essentially count the number of rows
I see when looking at txt4x6Display (regardless of whether they are carriage
returns or wrapped text).

Version: Access2002
Form Name: frmVocabDisplay
TextBox Name: txt4x6Display

Any help you can provide would be appreciated.

Thanks!!
 
M

Marshall Barton

Rob said:
I made a database of Terms and Definitons (long ones) to study for biology
exams. I often print out these terms on 4x6 flashcards (via a report I
made), therefore, "txt4x6Display" represents perfectly the size of a 4x6
flashcard. However, some of the definitions run long, and therefore some of
the info doesn't appear on the card. I would like an unbound text box
(perhaps, txtLineCount) to display a count of the number of lines in
txt4x6Display. A previous post showed how to count the number of carriage
returns...however, I need to be able to essentially count the number of rows
I see when looking at txt4x6Display (regardless of whether they are carriage
returns or wrapped text).

Version: Access2002
Form Name: frmVocabDisplay
TextBox Name: txt4x6Display


There's no easy way to count the lines as formatted in a
CanGrow text box.

You could use the TextHeight function at www.lebans.com to
determine the height that the text will be to hold all the
text.

I don't see where you can do much with the number of lines.
What were you planning to do with value if you could get it?

One thought is to use Stephen's function to see if the text
will fit in the text box's allowed space and reduce the font
size if it doesn't.
 
G

G. Vaught

Create an unbound text box at the far left of your 4x6 report. Delete the
label part. In the control source type =1. Under running sum change to read
Yes. This will number your report entries numerically.
 
G

Guest

Thanks for replying. The lebans site appears to be quite helpful as well.

If I could get a value that stated the number of lines, I would simply enter
code to change the color of the text box (red for instance). This would let
me know that I need to be less wordy. Thanks again, Rob.
 
M

Marshall Barton

Well, that seems easy enough, but you don't want the number
of lines of text. You only need to know if the text fits in
the text box's preset size and Stephen's TextHeight function
will tell you that:

If Me.thetextbox.Height < fTextHeight(Me.thetextbox) Then
Me.thetextbox.ForeColor = vbRed
Else
Me.thetextbox.ForeColor = vbBlack
End If

You could make this check in your data entry form (both
form's Current and thetextbox's AfterUpdate events) so you
could see the issue immediately. The ony trick here is to
make the form text box exactly the same size as the report's
text box.
 

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