Hi. There is no in-built function to do so, but it would be possible to write a custom function in VB.
What do you mean by lines, though? Is a line in your memo something that is ended by a certain defined punctuation mark? (question mark, period, exclamation mark)? Or do you just mean lines terminated by end-of-line markers (typically CR/LF combinations)?
Please advise
-Stewart
Originally posted by Briansmi1116
I am trying to find some code that will count the number of lines in a memo field. Is there any such a thing?
Thank you for replying. I call a line where it reaches the end of a field, and has to wrap around to the next line. I have users that just type notes in this field, and sometime don't even punctuate. Some notes are one line, some are several. What I'm trying to do so an if then statement concerning printing. for example, if the notes field is completely visible in the field, the it will not open the report with the notes, and print it. If the notes go beyond the height of the field, then it will open the notes report, and print. Let me know if you understand what I trying to do.
Hi Brian. I think I understand what you want to do - but it is simply not possible to count wrapped lines within the textbox.
I asked about what constitutes a line because without a clear definition a count has no meaning, and I'm sorry to say that the wrapping is of no help at all since wrapping is to do with internal character font sizes and widths, not the number of lines. In any event, text wrapping is an internal function of the textbox itself, not of any code which looks at the contents of the textbox.
I can't help you here - sorry.
You may wish to look at the 'can grow' property of a textbox on a report and set this to Yes. If the field is longer than can be fitted in the space available 'Can Grow' allows the field to extend vertically to fit the text.
The only possible approach to this, I think, would be to use a monospaced (fixed-width) font, such as OCR-B or Courier, count to find out how many characters comprise a "line" and then do something like
Lines = Len(Me.MemoFiel d)/LineLength
Most people avoid monospaced fonts, because they're not very pleasing to the eye and are, for most people, difficult to read. If the "can grow" property (for reports) that Stewart mentioned looks like it might be of use to you, I believe Stephen Lebans has a hack on his site that provides the same functionality for forms.
Comment