none
Limit Long Text field to 600 characters RRS feed

  • Question

  • Is there an easy way to limit the number of characters in a long text field in Access 2016?  I am creating a form that has limited space so I need to limit fields to 600 characters.
    Tuesday, February 7, 2017 7:29 PM

All replies

  • Hi,

    Not sure what form size has to do with field size. Are you saying you don't want to use scrollbars? To limit the chars for a Memo field, you may have to use code. Is it okay?

    Tuesday, February 7, 2017 7:43 PM
  • Hi,

    You might also be able to use a Validation Rule. For example:

    Len([MemoFieldName])<=600

    Hope it helps...

    Tuesday, February 7, 2017 7:46 PM
  • I've done something similar before:

    Private Sub txtMemo_KeyDown(KeyCode As Integer, Shift As Integer)
        '' Prevent new lines
        If Shift = 2 And KeyCode = 13 Then
            GoTo Cancel_KeyPress
        End If
        '' Prevent typing more than 144 chars
        If (Len(Me.txtMemo.text) > 600) And (KeyCode <> 8) Then
            GoTo Cancel_KeyPress
        End If
        '' Prevent Paste
        If (Shift = 2 And KeyCode = 86) Or (Shift = 1 And KeyCode = 45) Then
            GoTo Cancel_KeyPress
        End If
    Exit Sub
    Cancel_KeyPress:
        KeyCode = 0
    End Sub


    Tuesday, February 7, 2017 9:19 PM
  • Hi blnew,

    you just need to set the validation rule on the design view of form.

    it will work if you directly enter the data in the table from datasheet view.

    if you are using form then you can use Validation on form.

    where you can check the character length of control.

    example is already mentioned by HTHP.

    you can visit the link below to know more about this topic.

    Restrict data input by using validation rules

    List of Access validation rule examples

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, February 8, 2017 2:23 AM
    Moderator