Using a textbox that acts more like a simple word processor

unluckyuser

New Member
Joined
Jan 12, 2025
Messages
10
Office Version
  1. 2019
Platform
  1. Windows
I need to input user discussions of a patient by a nurse. The problem with a textbox is that when you press enter, it doesn't go down to the next line, instead, it moves to the next control.

What I need to do is something like this:
"
Jan 14, 7p.
Patient denies a/d/hi/si/avh. Med complaint
States he is hearing voices telling him to jump
from the window. Pacing floors

Call from mother who says this has been
going on for 3 days."

Then the next day, I need to retrieve this in a text box and allow typing of the next assessment, so we get several days of assessments in the box, the results of which are saved in a worksheet file. The problem I'm having is when you press the enter key, the textbox control doesn't end a sentence with a carriage return and move down for more typing. What it does is go to the next control.

What is needed is to continue the next day. VBA needs to pull up the jan 14 assessment, and allows the next assessment to be added, so you might end up with something like this:


Jan 14, 7p.
Patient denies a/d/hi/si/avh. Med complaint
States he is hearing voices telling him to jump
from the window. Pacing floors

Call from mother who says this has been
going on for 3 days."

Jan 15 7p.
Patient states he is no longer hearing voices.
Med selective. Refused vistaril. WAnts stuffed
dog from his home. endorses anxiety of 6
Depression of 8.

States he is waiting for his visit with Dr.
Smith. etc etc.

Jan 16
on and on, etc.


over a few days, you might have several assessments that can be scrolled through while adding the next assessment. So it's a growing narrative. The textbox is loaded with it when the patient is edited. basically, I need the text box to hold the text and wordwrap within the box. I just need it to process carriage returns and when the user is finished editing, the can press the "save assessment" button, so it's saved to the data spread sheet.

Sorry if I've been unclear. Thanks!
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Is this an ActiveX control on a userform? A forms control on a sheet? Did you try ctrl+Enter or alt+Enter?
 
Upvote 0
Is this an ActiveX control on a userform? A forms control on a sheet? Did you try ctrl+Enter or alt+Enter?
This is just the default textbox in a vba userform. Hit enter, it goes to the next control. I need slightly expanded word processing ability, similar to a note you can attach a comment to a cell in a spreadsheet. If I could create those comments and edit them with vba, that would be perfect.
 
Upvote 0
Then what I said will work (should). However, you must set the multi line property to true.
 
Upvote 0
Then what I said will work (should). However, you must set the multi line property to true.
I've done that. However, hitting the enter key doesn't produce a carriage return and then you're typing on the next line. It exits that control because it thinks you're done editing. If you look at entering a comment in a spreadsheet cell, that's precisely what I need. If I could modify a userform text control and make it behave the same way as typing/editing in the comment.
 
Upvote 0
Works for me if the property is set and I type ctrl+Enter at the end of a line
1736977676386.png
 
Upvote 0
Solution
Works for me if the property is set and I type ctrl+Enter at the end of a line
View attachment 121290
That is a reasonably workable solution. I give you props here. I'd have never figured that out :). Any way to have that work on just hitting the enter key? When they're done editing, I want them to click a button which then saves the edited work. I'm dealing with end users who are like monkeys typing on a keyboard.
 
Upvote 0
Works for me if the property is set and I type ctrl+Enter at the end of a line
View attachment 121290
The more I think about it the more I like your solution. I don't want to add anything more than the vanilla controls that VBA gives by default. I am running in an environment that adding a bunch of activeX controls will crash the application. So I need to keep it as thin as possible. This certainly achieves that.
 
Upvote 0
adding a bunch of activeX controls will crash the application.
AFAIK, the "default" control for a userform is an ActiveX control so I don't understand that. Where you have a choice is on a sheet, but not a userform? I could be wrong about that. There might be a way to do what you asked 2 posts ago but I would have to experiment with key events (e.g. KeyDown, KeyUp, and the like). If that is of interest, let me know. Otherwise I don't think I need to experiment for something that isn't wanted. However, it would probably involve SendKeys method, but only if the control with the focus (?) is that textbox. IMO SendKeys should only be used when there's no alternative. In this case, the "monkeys" can probably be trained to use the Ctrl+Enter combination if you have enough bananas. :)
 
Upvote 0
AFAIK, the "default" control for a userform is an ActiveX control so I don't understand that. Where you have a choice is on a sheet, but not a userform? I could be wrong about that. There might be a way to do what you asked 2 posts ago but I would have to experiment with key events (e.g. KeyDown, KeyUp, and the like). If that is of interest, let me know. Otherwise I don't think I need to experiment for something that isn't wanted. However, it would probably involve SendKeys method, but only if the control with the focus (?) is that textbox. IMO SendKeys should only be used when there's no alternative. In this case, the "monkeys" can probably be trained to use the Ctrl+Enter combination if you have enough bananas. :)
Yeah, I think that's a small matter. I want to keep it as simple as possible.
 
Upvote 0

Forum statistics

Threads
1,225,616
Messages
6,186,016
Members
453,334
Latest member
Prakash Jha

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top