How limit # of characters allowed in Access memo field

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.
 
G

Guest

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
 
D

Douglas J. Steele

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.
 

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