Limiting text in a memo field

jclaydon

Registered User.
Local time
Today, 19:22
Joined
Jul 29, 2004
Messages
11
Hi,

Probably a really simple question, but is causing me problems! I need to be able to limit the amount of characters that can be entered into a field. For text fields I can just enter the relevant field size, but can not find an equivalent for a memo field. Validation rule warns you that there are to many characters, but doesn't seem to actually limit you.

Any suggestions would be appreciated.

J
 
Limit Text

I assume you are using a form.

In the On Change Event of the Memo Field put something like this:

******
If Len(Me.Memo.Text) > 10 Then
Me.Memo.Text = Left(Me.Memo.Text, 10)
MsgBox " You reached the Limit!", vbOKOnly, ""
Exit Sub
Else
End If
******

Replace '10' with the number of characters you want to allow.
Replace 'Memo' with the actual name of the Memo field.
 
Excellent, that's worked a treat. Many thanks
 
Can anyone please assist me with this. I am a newbie with all of this. I have entered the following based on the information above:

If Len(Me.HomePageEvents.Text) > 375 Then
Me.Memo.Text = Left(Me.HomePageEvents.Text, 375)
MsgBox " You reached the Limit!", vbOKOnly, ""
Exit Sub
Else
End If​

I replaced MEMO with the name of the my memo field (HomePageEvents)
I replaced 10 with 375 which is the max characters I want to allow.

I added the above to the On Change Event and get the following error:

The expression On Change you entered as the event property setting produced the following error: Invalid outside procedure.

Is this not how the event should look?

Private Sub HomePageEvents_Change()

If Len(Me.HomePageEvents.Text) > 375 Then
Me.Memo.Text = Left(Me.HomePageEvents.Text, 375)
MsgBox " You reached the Limit!", vbOKOnly, ""
Exit Sub
Else
End If

End Sub​
 
Try this
***********************************
Private Sub HomePageEvents_Change()

If Len(Me.HomePageEvents.Text) > 375 Then
Me.HomePageEvents.Text = Left(Me.HomePageEvents.Text, 375)
MsgBox " You reached the Limit!", vbOKOnly, ""
Exit Sub
Else
End If

End Sub
 
If you open the form and view the property of the field, what is the actual name of the field?
 

Users who are viewing this thread

Back
Top Bottom