<p>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)?</p>

[{'answer_id': 18972, 'author': 'Mauro', 'author_id': 2208, 'author_profile': 'https://Stackoverflow.com/users/2208', 'pm_score': 0, 'selected': False, 'text': '<p>not entirely sure about that one, you should be able to remove the line breaks when you render the content though, or even run a vbscript to clear it out, you just need to check for chr(13) or vbCrLf.</p>\n'}, {'answer_id': 19063, 'author': 'Ian Patrick Hughes', 'author_id': 2213, 'author_profile': 'https://Stackoverflow.com/users/2213', 'pm_score': 2, 'selected': False, 'text': "<p>The way I did it before (and the last time I worked in Access was around '97 so my memory is not so hot) was raising a key-up event and executing a VBA function. It's a similar method to what you do with an AJAX suggest text box in a modern webform application, but as I recall it could get tripped up if your Access form has other events which tend to occur frequently such a onMouseMove over the entire form object.</p>\n"}, {'answer_id': 20255, 'author': 'BIBD', 'author_id': 685, 'author_profile': 'https://Stackoverflow.com/users/685', 'pm_score': 4, 'selected': True, 'text': "<p>I was able to do it on using KeyPress event.\nHere's the code example:</p>\n\n<pre><code>Private Sub SingleLineTextBox_ KeyPress(ByRef KeyAscii As Integer)\n    If KeyAscii = 10 _\n        or KeyAscii = 13 Then\n            '10 -&gt; Ctrl-Enter. AKA ^J or ctrl-j\n            '13 -&gt; Enter.      AKA ^M or ctrl-m\n        KeyAscii = 0  'clear the the KeyPress\n    End If\nEnd Sub\n</code></pre>\n"}, {'answer_id': 22711, 'author': 'Jason Z', 'author_id': 2470, 'author_profile': 'https://Stackoverflow.com/users/2470', 'pm_score': 0, 'selected': False, 'text': '<p>If you don\'t want an event interfering, you can set up the Validation Rule property for the textbox to be</p>\n\n<pre><code>NOT LIKE "*"+Chr(10)+"*" OR "*"+Chr(13)+"*"\n</code></pre>\n\n<p>You will probably also want to set the Validation Text to explain specifically why Access is throwing up an error box.</p>\n'}, {'answer_id': 67730, 'author': 'David-W-Fenton', 'author_id': 9787, 'author_profile': 'https://Stackoverflow.com/users/9787', 'pm_score': 2, 'selected': False, 'text': "<p>Using the KeyPress event means that your code will fire every time the user types. This can lead to screen flickering and other problems (the OnChange event would be the same).</p>\n\n<p>It seems to me that you should use a single event to strip out the CrLf's, and the correct event would be AfterUpdate. You'd simply do this:</p>\n\n<pre><code>  If InStr(Me!MyMemoControl, vbCrLf) Then\n     Me!MyMemoControl = Replace(Me!MyMemoControl, vbCrLf, vbNullString)\n  End If\n</code></pre>\n\n<p>Note the use of the Access global constants, vbCrLf (for Chr(10) &amp; Chr(13)) and vbNullString (for zero-length string).</p>\n\n<p>Using a validation rule means that you're going to pop up an ugly error message to your user, but provide them with little in the way of tools to correct the problem. The AfterUpdate approach is much cleaner and easier for the users, seems to me.</p>\n"}, {'answer_id': 29218275, 'author': 'kernelk', 'author_id': 1305420, 'author_profile': 'https://Stackoverflow.com/users/1305420', 'pm_score': 1, 'selected': False, 'text': "<p>Thanks Ian and BIBD. I created a public sub based on your answer that is reusable.</p>\n\n<pre><code>Public Sub PreventNewlines(ByRef KeyAscii As Integer)\n    If KeyAscii = 10 Or KeyAscii = 13 Then KeyAscii = 0\nEnd Sub\n\nPrivate Sub textbox_KeyPress(KeyAscii As Integer)\n    Call PreventNewlines(KeyAscii)\nEnd Sub\n</code></pre>\n\n<p>Screen flicker should never be an issue, as these are handled events, not constant polling (and it's per control further limiting the scope). Seems to me like an invalid argument, as every text editor is executing some code per keystroke.</p>\n\n<p>Thanks</p>\n"}, {'answer_id': 60349089, 'author': 'John Litchfield', 'author_id': 12942182, 'author_profile': 'https://Stackoverflow.com/users/12942182', 'pm_score': 0, 'selected': False, 'text': '<p>Jason\'s response works well. Just to add to it..</p>\n\n<p>If you want to allow the user to leave the text box blank, you could use this:</p>\n\n<p>Not Like "<em>"+Chr(10)+"</em>" Or "<em>"+Chr(13)+"</em>" Or Is Null</p>\n'}]
['https://Stackoverflow.com/questions/18955', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/685/']