Group:  Microsoft Access ยป microsoft.public.access.macros
Thread: Limiting the number of lines in a textbox

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Limiting the number of lines in a textbox
"hesperian" <hesperian[ at ]charter.net> 23.02.2006 18:26:55
I have a form with a long textbox on it used for inputting notes for an
order. It is roughly 4 lines of text high. It is bound to a control that
is also used in a report. If the user inputs more that the 4 lines of text
that are visible on the form it allows him to keep typing as long as he has
not reached the field size limit of characters, however the report is not
able to show any information that is in the field after the fourth line due
to its size.

The restrictions that I have to work within.
I can not reduce the field size limit.
I can not tell the users not to use carriage returns in the field to
create new lines.
I can not adjust the size of the field in either the form or the report.

I am at my wits end on this as the only thing that I can think of trying to
do is limiting the number of lines that are available in the textbox,
however I can see no way to accomplish this.

Any input and help is greatly appreciated.
thanks in advance
Hesperian


Re: Limiting the number of lines in a textbox
Steve Schapel <schapel[ at ]mvps.org.ns> 24.02.2006 08:59:16
Hesperian,

Well, this is a design issue. What aspects of design of the application
do you have rights to? If you are supposed to be working with the
application, but can't change the Field Size property of a field, you
are very restricted. Are you able to write code or macro to run on the
form? You can't really count the number of lines in a textbox, but you
could do a user-defined function that counts the number of characters
and the number of carriage returns and pops up a warning to the user.

--
Steve Schapel, Microsoft Access MVP


hesperian wrote:
[Quoted Text]
> I have a form with a long textbox on it used for inputting notes for an
> order. It is roughly 4 lines of text high. It is bound to a control that
> is also used in a report. If the user inputs more that the 4 lines of text
> that are visible on the form it allows him to keep typing as long as he has
> not reached the field size limit of characters, however the report is not
> able to show any information that is in the field after the fourth line due
> to its size.
>
> The restrictions that I have to work within.
> I can not reduce the field size limit.
> I can not tell the users not to use carriage returns in the field to
> create new lines.
> I can not adjust the size of the field in either the form or the report.
>
> I am at my wits end on this as the only thing that I can think of trying to
> do is limiting the number of lines that are available in the textbox,
> however I can see no way to accomplish this.
>
> Any input and help is greatly appreciated.
> thanks in advance
> Hesperian
>
>
Re: Limiting the number of lines in a textbox
"hesperian" <hesperian[ at ]charter.net> 24.02.2006 18:29:15
Steve,

I have full access to all of the forms and code, however I don not have
permission to change the layouts of the "look" of the forms. The essence of
my situation is that the company that I work for has an access database that
is being used to track manufacturing orders. The person who put all of this
together is no longer with the company, however the company has grown quite
accustomed how this application performs.

From a programming standpoint I have access to everything I need access to,
but from a policy standpoint I have to make sure that the look and feel of
the application does not change much from what it already is.

If you could give me some ideas concerning the user defined function for
counting the carriage returns I would be gratefull.

Thanks
hesperian
"Steve Schapel" <schapel[ at ]mvps.org.ns> wrote in message
news:%23LpIYCSOGHA.2124[ at ]TK2MSFTNGP14.phx.gbl...
[Quoted Text]
> Hesperian,
>
> Well, this is a design issue. What aspects of design of the application
> do you have rights to? If you are supposed to be working with the
> application, but can't change the Field Size property of a field, you are
> very restricted. Are you able to write code or macro to run on the form?
> You can't really count the number of lines in a textbox, but you could do
> a user-defined function that counts the number of characters and the
> number of carriage returns and pops up a warning to the user.
>
> --
> Steve Schapel, Microsoft Access MVP
>
>
> hesperian wrote:
>> I have a form with a long textbox on it used for inputting notes for an
>> order. It is roughly 4 lines of text high. It is bound to a control
>> that is also used in a report. If the user inputs more that the 4 lines
>> of text that are visible on the form it allows him to keep typing as long
>> as he has not reached the field size limit of characters, however the
>> report is not able to show any information that is in the field after the
>> fourth line due to its size.
>>
>> The restrictions that I have to work within.
>> I can not reduce the field size limit.
>> I can not tell the users not to use carriage returns in the field to
>> create new lines.
>> I can not adjust the size of the field in either the form or the
>> report.
>>
>> I am at my wits end on this as the only thing that I can think of trying
>> to do is limiting the number of lines that are available in the textbox,
>> however I can see no way to accomplish this.
>>
>> Any input and help is greatly appreciated.
>> thanks in advance
>> Hesperian


Re: Limiting the number of lines in a textbox
Steve Schapel <schapel[ at ]mvps.org.ns> 24.02.2006 19:12:53
Hesperian,

Well, I would have thought that changing the Field Size property of a
field, which in practice does indeed need to be restricted, would not be
violating the "make sure that the look and feel of the application does
not change much from what it already is" rule.

Anyway, untested "air code"...

Public Function TextTooLong(InputText As String) As Boolean
Dim CRs As Integer
Dim TextLength As Integer
Dim TestText As String
Dim CRPosition As Integer
TestText = InputText
TextLength = Len(InputText)
CRPosition = InStr(TestText, Chr(13) & Chr(10))
Do Until CRPosition = 0
CRs = CRs + 1
TestText = Mid(TestText, CRPosition + 1)
CRPosition = InStr(TestText, Chr(13) & Chr(10))
Loop
If TextLength > 120 _
Or CRs = 1 And TextLength > 100 _
Or CRs = 2 And TextLength > 70
Or CRs > 2 Then
TextTooLong = True
End If
End Function

And then, on the AfterUpdate event of the applicable textbox on your form...
If TextTooLong(Me.NameOfTextbox) Then
MsgBox "Hey, this is too long to fit on the report!"
End If

Of course, the "rules" about length of text and number of carriage
returns allowable will necessarily be arbitrary, and will sometimes flag
as too long stuff that will in fact easily fit, and may at other times
allow an entry that is in fact too long, so this will not be a precise
science.

--
Steve Schapel, Microsoft Access MVP


hesperian wrote:
[Quoted Text]
> Steve,
>
> I have full access to all of the forms and code, however I don not have
> permission to change the layouts of the "look" of the forms. The essence of
> my situation is that the company that I work for has an access database that
> is being used to track manufacturing orders. The person who put all of this
> together is no longer with the company, however the company has grown quite
> accustomed how this application performs.
>
> From a programming standpoint I have access to everything I need access to,
> but from a policy standpoint I have to make sure that the look and feel of
> the application does not change much from what it already is.
>
> If you could give me some ideas concerning the user defined function for
> counting the carriage returns I would be gratefull.
>
> Thanks
> hesperian

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net