How Can I prevent ctrl + enter (carriage return) on a text box?

  • Thread starter Thread starter Aki Nomura
  • Start date Start date
A

Aki Nomura

I don't want users to insert a carriage return on a text box.
In the text box property, there is [Enter Key Behaviour] but [Ctrl + Enter
Key Behaviour].
How can I prevent this?
Help!
 
Try this in the KeyDown event of the textbox to cancel the entry.

Private Sub Text3_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 And (Shift And acCtrlMask) > 0 Then
KeyCode = 0
End If
End Sub
 
Thank you.
So there is no such a setting then.....

Wayne Morgan said:
Try this in the KeyDown event of the textbox to cancel the entry.

Private Sub Text3_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 And (Shift And acCtrlMask) > 0 Then
KeyCode = 0
End If
End Sub

--
Wayne Morgan
MS Access MVP


Aki Nomura said:
I don't want users to insert a carriage return on a text box.
In the text box property, there is [Enter Key Behaviour] but [Ctrl +
Enter Key Behaviour].
How can I prevent this?
Help!
 
You can also imagine analyzing what the user entered and ignore everything
after the first line break.

Also display a warning message through a message box, reminding the user
that the field in question is "monoline" and that muilti line input is not
wished for. Of course, only display it when the data entered is invalid.
After a few tries the user will stop trying.

:P

Francois
 
Back
Top