Note: This tip New Line is suitable for all versions of Microsoft Access.
Question
The application I'm currently building has a table of memo objects. The users should be able to create memos from a form, and when they are writing the memo, the return key should give them a carriage return rather than take them to the next field.
Answer
To enable the user to enter a carraige return, rather than going to a new field in a text or memo field, try the following:
With the form in Design view, double click on the text or memo box that you wish to set this option for;
Double clicking opens the Property window;
Click on the ‘Other’ tab and make sure the ‘Enter Key Behaviour’ says new line in field;
This should be the default for the memo field (in the later versions of Microsoft Access), but you will need to change it for a text field.
As I write this I realise, this might not answer everyone questions i.e. how do I achieve this for a label, a message box or how to write it in code (VBA). Therefore here a few more examples.
Label
For a label hold down the 'Ctrl' key whilst pressing the 'Enter' Key.
Message Box (Macro)
If you are creating a message box (msgbox) in a Macro you may wish to create a message box over a couple of lines i.e. the message box may contain the following message:
You have opened a message box:
Click 'Yes' to continue
Click 'No' to cancel
To space it out to correctly display your message, hold down the 'Ctrl' key whilst pressing the 'Enter' Key. This will make it seem like the previous line(s) have disappeared, but they are still there, but you cannot see them. When done, you will just see the first line of the message, but if you run the macro you will see that they are all there.
Code (VBA)
If writing code, and you are creating text for a message box, label etc, then when you want the text to move tothe next line type in the following:
vbCrLf
This will force a new line.
If you would like to learn VBA code, then Click Here
Finished with New Line tip, then return to Simply Access Home Page
or
or return to Microsoft Access Forms