Making ENTER Add Lines in a Text Box

Summary:

Text boxes in Microsoft Access do not support using the ENTER key to
add lines within a field. When ENTER is pressed in a text box, the
focus is placed on the next field or control. This article explains
how to change the functionality of pressing ENTER in text boxes so
that it adds lines instead of changing the focus.

More Information:

The following function changes the behavior of the ENTER key in text
boxes to allow adding lines instead of changing the focus to a
different field or control. This code should be attached to the
BeforeUpdate event of the text box.

NOTE: There must be some change to the text box before this code will
work because Microsoft Access evaluates controls only after they have
been changed (dirtied).

In the Declarations section of a Module, type the following:

   Declare Function GetKeyState% Lib "user.exe" (ByVal nKey%)
   Const VK_RETURN = &HD

The following is the actual code:

   Function MakeEnterWork()
      If GetKeyState(VK_RETURN) < 0 Then
         DoCmd CancelEvent
         SendKeys "^{ENTER}"
      End If
   End Function
