how do I limit the length of the memo field

H

Harold Good

Hi,

Is there an easy way to limit the size of the memo field?

I'd like to limit it to about 100 words or about 500 characters so that
people can't enter too much data.

Thanks,
Harold
 
G

Graham Mandeno

Hi Harold

You could use the Change event of your textbox to monitor the length of the
text and give a message when a limit has been reached. For example:

Private Sub MyMemoField_Change()
With MyMemoField
If Len(.Text) > 500 Then
.Text = Left( .Text, 500 )
MsgBox "Please try to be a little less verbose"
End If
End With
End Sub

You could even have a "length countdown display" like a cell phone when you
send a text message:

txtCharsLeft = 500 - Len(MyMemoField.Text)
 
H

Harold Good

Hi, I have done this below and it works well. But with the
txtCharsLeft = 500 - Len(MyMemoField.Text)
I wasn't sure where to put it, so I put it in the ControlSource.

But is there any way to get it to countdown live, as the letters are being
typed?
As it is now, it doesn't update until I click out of the memo section.

Thanks,
Harold

===============
Graham Mandeno said:
Hi Harold

You could use the Change event of your textbox to monitor the length of
the text and give a message when a limit has been reached. For example:

Private Sub MyMemoField_Change()
With MyMemoField
If Len(.Text) > 500 Then
.Text = Left( .Text, 500 )
MsgBox "Please try to be a little less verbose"
End If
End With
End Sub

You could even have a "length countdown display" like a cell phone when
you send a text message:

txtCharsLeft = 500 - Len(MyMemoField.Text)

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Harold Good said:
Hi,

Is there an easy way to limit the size of the memo field?

I'd like to limit it to about 100 words or about 500 characters so that
people can't enter too much data.

Thanks,
Harold
 
G

Graham Mandeno

Hi Harold

Sorry if that wasn't clear. You should add it as another line in the Change
event procedure for the memo textbox.

Add a textbox named txtCharsLeft and make it disabled and locked. Then add
this line just before the "End With":

txtCharsLeft = 500 - Len(.Text)

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Harold Good said:
Hi, I have done this below and it works well. But with the
txtCharsLeft = 500 - Len(MyMemoField.Text)
I wasn't sure where to put it, so I put it in the ControlSource.

But is there any way to get it to countdown live, as the letters are being
typed?
As it is now, it doesn't update until I click out of the memo section.

Thanks,
Harold

===============
Graham Mandeno said:
Hi Harold

You could use the Change event of your textbox to monitor the length of
the text and give a message when a limit has been reached. For example:

Private Sub MyMemoField_Change()
With MyMemoField
If Len(.Text) > 500 Then
.Text = Left( .Text, 500 )
MsgBox "Please try to be a little less verbose"
End If
End With
End Sub

You could even have a "length countdown display" like a cell phone when
you send a text message:

txtCharsLeft = 500 - Len(MyMemoField.Text)

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Harold Good said:
Hi,

Is there an easy way to limit the size of the memo field?

I'd like to limit it to about 100 words or about 500 characters so that
people can't enter too much data.

Thanks,
Harold
 
H

Harold Good

This is great, counting now keeps up with letters being entered!

Thanks much for your help,
Harold
==================
Graham Mandeno said:
Hi Harold

Sorry if that wasn't clear. You should add it as another line in the
Change event procedure for the memo textbox.

Add a textbox named txtCharsLeft and make it disabled and locked. Then
add this line just before the "End With":

txtCharsLeft = 500 - Len(.Text)

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Harold Good said:
Hi, I have done this below and it works well. But with the
txtCharsLeft = 500 - Len(MyMemoField.Text)
I wasn't sure where to put it, so I put it in the ControlSource.

But is there any way to get it to countdown live, as the letters are
being typed?
As it is now, it doesn't update until I click out of the memo section.

Thanks,
Harold

===============
Graham Mandeno said:
Hi Harold

You could use the Change event of your textbox to monitor the length of
the text and give a message when a limit has been reached. For example:

Private Sub MyMemoField_Change()
With MyMemoField
If Len(.Text) > 500 Then
.Text = Left( .Text, 500 )
MsgBox "Please try to be a little less verbose"
End If
End With
End Sub

You could even have a "length countdown display" like a cell phone when
you send a text message:

txtCharsLeft = 500 - Len(MyMemoField.Text)

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Hi,

Is there an easy way to limit the size of the memo field?

I'd like to limit it to about 100 words or about 500 characters so that
people can't enter too much data.

Thanks,
Harold
 

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