How limit # of characters allowed in Access memo field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In working with Access 2003, I want to disallow the scrolling of a memo
field, which happens automatically if you type beyond the last line.
Limiting the # of lines would do as well. Of course, either the # to use,
whether lines or characters, would depend upon the font, but since that can't
be changed by the end user, that would not pose a problem.
 
Hi Allen,

I followed your instructions, but cannot get the code to work. I created a
module and copied your 2 subs.

I then went to the On Key Press control for the comment box and pasted this
in the event procedure:

Private Sub Comments_KeyPress(KeyAscii As Integer)
Call LimitKeyPress.LimitKeyPress
End Sub

I receive the following error:

Compile Error:
Argurment Not Optional
 
You're not calling LimitKeyPress correctly.

As Allen's page states, "to limit a control named "City" to 40 characters,
its KeyPress event procedure is:

Call LimitKeyPress(Me.City, 40, KeyAscii)"

That means you need:

Private Sub Comments_KeyPress(KeyAscii As Integer)
Call LimitKeyPress(Me.Comments, 100, KeyAscii)
End Sub

to limit the input to 100 characters.
 
Back
Top