Can Memo character size be limited?

S

Shao

Is there a way to limit the character size for "Memo" data
type? I want the limit to be 400 character size.

For the Data Type "Text" I can change the field size to
anything less than 255 character size. However, Memo
65,535 character size doesn't have a Field Size option in
the Field Properties.

The only other way I can figure is to make two Text field
names with 200 character size limits. Is there any trick
to limiting the character size of Memo?

Thanks for the help.
 
A

Arvin Meyer

Shao said:
Is there a way to limit the character size for "Memo" data
type? I want the limit to be 400 character size.

How about something like this in a module:

Public Sub LimitChars(KeyAscii, MaxLength)
Dim ctl As Control
Set ctl = Screen.ActiveControl
If IsNull(ctl.Text) Then Exit Sub
If KeyAscii < 32 Then Exit Sub
If Len(ctl.Text) >= MaxLength Then KeyAscii = 0
End Sub

'Then in the KeyPress event of your control (txtFieldName) call it.

Private Sub txtFieldName_KeyPress(KeyAscii As Integer)
LimitChars KeyAscii, 400
End Sub
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 

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