Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

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).

↑ Back to the top


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.

↑ Back to the top


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
				

↑ Back to the top


References

For additional information about disabling keystrokes, click the article number below to view the article in the Microsoft Knowledge Base:
208826� ACC2000: How to Disable PAGE UP and PAGE DOWN Keys in a Form

↑ Back to the top


Keywords: KB210207, kbinfo, kbhowto

↑ Back to the top

Article Info
Article ID : 210207
Revision : 4
Created on : 10/11/2006
Published on : 10/11/2006
Exists online : False
Views : 484