Microsoft KB Archive/210207

= ACC2000: How to Disable CTRL+ENTER in a Text Box or Memo Control =

Article ID: 210207

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q210207



Moderate: Requires basic macro, coding, and interoperability skills.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).



SUMMARY
In Microsoft Access 2000, a user can insert a carriage return/line feed into a bound text box by pressing CTRL+ENTER. This key combination is a Windows shortcut recognized by all Microsoft Office products, including Access. However, in certain situations, you may want to prevent the user from inserting a carriage return/line feed into a given text box. This article demonstrates a user-defined Sub procedure that you can use to intercept these keystrokes within a given text box.



MORE INFORMATION
When a user presses CTRL+ENTER from within a bound text box on a form, a Windows shortcut results. The result is sent directly to the operating system and cannot be suppressed by Microsoft Access or any other program running under Windows.

To intercept the carriage return/line feed effect of these keystrokes, insert the following event procedure in the KeyDown event of the text box:

Sub Text1_KeyDown (keycode As Integer, shift As Integer) Dim shiftdown As Variant shiftdown = (Shift And CTRL_MASK) If shiftdown And (KeyCode = 13) Then SendKeys "{BS}" End Sub

