在 MS Access 中禁用多行字段
问题描述:
有没有办法禁止在文本框中输入多行条目(即,我想阻止我的用户按 ctrl-enter 来获取换行符)?
Is there a way to disable entering multi-line entries in a Text Box (i.e., I'd like to stop my users from doing ctrl-enter to get a newline)?
答
我能够使用 KeyPress 事件来做到这一点.下面是代码示例:
I was able to do it on using KeyPress event. Here's the code example:
Private Sub SingleLineTextBox_ KeyPress(ByRef KeyAscii As Integer)
If KeyAscii = 10 _
or KeyAscii = 13 Then
'10 -> Ctrl-Enter. AKA ^J or ctrl-j
'13 -> Enter. AKA ^M or ctrl-m
KeyAscii = 0 'clear the the KeyPress
End If
End Sub