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

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!
 
W

Wayne Morgan

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
 
A

Aki Nomura

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!
 
F

François Uldry

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top