如何限制访问的字符数超过255 [英] how to limit the characters in access to more than 255

查看:125
本文介绍了如何限制访问的字符数超过255的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何限制访问的字符数超过255?例如,我希望它在备忘录或文本框中将其限制为最多300个字符.

How to limit the characters in access to more than 255? for example, I want it the memo or text box to limit it to max 300 characters.

在Access 2010中

In Access 2010

推荐答案

如果要将表中的备注字段限制为不超过300个字符,请在设计视图中打开表,并将其添加为字段的验证规则"属性.

If you want to limit a memo field in a table to no more than 300 characters, open the table in design view and add this as the field's Validation Rule property.

Len([memo_field])<301

将您的字段名称替换为memo_field.您还可以添加验证文本"属性,以在违反规则时显示更加用户友好的消息.没有验证文本,该规则将产生此消息……对于用户而言可能不是很清楚:

Substitute your field's name for memo_field. You can also add a Validation Text property to display a more user-friendly message when the rule is violated. With no Validation Text, that rule would produce this message ... which might not be very clear to a user:

*为"YourTableName.memo_field"设置的验证规则"Len([memo_field])< 301"禁止使用一个或多个值.输入此字段的表达式可以接受的值.*

*One or more values are prohibited by the validation rule 'Len([memo_field])<301' set for 'YourTableName.memo_field'. Enter a value that the expression for this field can accept.*

您还提到了一个文本框.如果它是绑定到备注字段的文本框,则可以在文本框的更新前"事件中验证字符长度.如果文本框名为txtMemo_field:

You also mentioned a text box. If it is a text box bound to a memo field, you can validate the character length in the text box's Before Update event. If the text box is named txtMemo_field:

Private Sub txtMemo_field_BeforeUpdate(Cancel As Integer)
    If Len(Me.txtMemo_field) > 300 Then
        MsgBox "Please limit data to maximum of 300 characters."
        Cancel = True
    End If
End Sub

在消息框之后,光标仍将位于文本框中,并且在不为txtMemo_field提供可接受值的情况下,不允许用户移动到另一个表单域.

After the message box, the cursor will be still located within the text box, and the user will not be allowed to move to another form field without supplying an acceptable value for txtMemo_field.

这篇关于如何限制访问的字符数超过255的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆