Forum Statistics
- Forum Members:
- Total Threads:
- Total Posts: 11
There are 1 users currently browsing forums.
|
 |

07-04-2009, 11:12 AM
|
|
Valued Forum Contributor
|
|
Join Date: 03 Jun 2008
Posts: 334
|
|
|
Force Display of Vertical Scroll Bars
Please Register to Remove these Ads
Hi,
I have created a form that has two textboxes on. It is used to edit existing data that is selected by a combobox on the same form.
Is there a way to force the textboxes to show scroll bars if the text exceeds the textbox height or just have them always shown?
It is difficult to distinguish on some of the data whether the data goes beyond what is visible. Without actually clicking into that textbox the scroll bars will not show.
Is this possible?
Thank you in advance
Last edited by jpruffle; 07-04-2009 at 12:55 PM.
|

07-04-2009, 11:21 AM
|
 |
Forum Guru
|
|
Join Date: 10 May 2004
Location: Essex, UK
MS Office Version:2003 & 2007 sp2
Posts: 7,220
|
|
|
re: Force Display of Vertical Scroll Bars
From a recent thread
http://www.excelforum.com/excel-prog...in-a-form.html
Code:
Private Sub UserForm_Initialize()
With TextBox2
.TabIndex = 0
.ScrollBars = fmScrollBarsVertical
.SelStart = 0
End With
End Sub
|

07-04-2009, 11:40 AM
|
|
Valued Forum Contributor
|
|
Join Date: 03 Jun 2008
Posts: 334
|
|
|
re: Force Display of Vertical Scroll Bars
Thank you for the quick reply.
I did read that thread but wondered if it was possible for two textboxes to display the scrollbars at the same time? As you can only set the focus on one item I assume not?
Thank you in advance
|

07-04-2009, 11:48 AM
|
 |
Forum Guru
|
|
Join Date: 10 May 2004
Location: Essex, UK
MS Office Version:2003 & 2007 sp2
Posts: 7,220
|
|
|
re: Force Display of Vertical Scroll Bars
When the textboxes are preloaded with text the scrollbars get a bit fussy.
If you set the TabIndex to the second textbox and then in the activate event you set focus to the first textbox it appears to work.
Code:
Private Sub UserForm_Activate()
TextBox1.SetFocus
End Sub
Private Sub UserForm_Initialize()
With TextBox1
.WordWrap = True
.TabIndex = 0
.ScrollBars = fmScrollBarsVertical
.SelStart = 0
End With
With TextBox2
.WordWrap = True
.TabIndex = 0
.ScrollBars = fmScrollBarsVertical
.SelStart = 0
End With
End Sub
|

07-04-2009, 11:57 AM
|
|
Valued Forum Contributor
|
|
Join Date: 03 Jun 2008
Posts: 334
|
|
|
re: Force Display of Vertical Scroll Bars
Again thank you for the quick reply.
I tried your method but unfortunately as the data gets changed and loaded after the form has initialised (i.e. to edit it) it doesn't seem to work.
As an alternative can any code be added so for example if the textbox exceeds 75 in height then show a label "Select for more Info". Or something like that?
|

07-04-2009, 12:00 PM
|
 |
Forum Guru
|
|
Join Date: 10 May 2004
Location: Essex, UK
MS Office Version:2003 & 2007 sp2
Posts: 7,220
|
|
|
re: Force Display of Vertical Scroll Bars
you need to post example as I can not guess the order of events occurring with code I can not see.
|

07-04-2009, 12:17 PM
|
|
Valued Forum Contributor
|
|
Join Date: 03 Jun 2008
Posts: 334
|
|
|
re: Force Display of Vertical Scroll Bars
The form is part of a very large spreadsheet so I have copied it over to a blank worksheet. However the functionality and data is not present.
On reflection I would almost prefer the ability to add text if the textbox exceeded a given height is that possible anyway?
I have attached my file.
Again thank you in advance.
|

07-04-2009, 12:24 PM
|
 |
Forum Guru
|
|
Join Date: 10 May 2004
Location: Essex, UK
MS Office Version:2003 & 2007 sp2
Posts: 7,220
|
|
|
re: Force Display of Vertical Scroll Bars
Text boxes do not show the scrollbars until they contain text that required scrolling
I don't understand what you mean.
Quote:
|
I would almost prefer the ability to add text if the textbox exceeded a given height is that possible anyway?
|
|

07-04-2009, 12:35 PM
|
|
Valued Forum Contributor
|
|
Join Date: 03 Jun 2008
Posts: 334
|
|
|
re: Force Display of Vertical Scroll Bars
Apologies.
The form I attached can be used to add or edit existing data. It is more often used as a quick reference to look at an issue. So the user simply add an ID number and the relevant data is shown.
As the info and status textboxes do not show scroll bars at a quick glance the user is unable to determine whether there is more information further down without physically clicking into the textbox. I wanted to make that process quicker. I tried your example but I am unsure how when I retrieve the data how to show the scroll bars.
In relation to my second query in regarding textbox height. I was being stupid! I wondered if it might be possible for vba to know if the text inside the box is greater than say the text height. If so then show a label saying that it is, which again would quickly show the user that they need to click into the textbox.
Ultimately I'll tell the user to stop being lazy but thought it'd be worth a try.
Thank you in advance
|

07-04-2009, 12:46 PM
|
 |
Forum Guru
|
|
Join Date: 10 May 2004
Location: Essex, UK
MS Office Version:2003 & 2007 sp2
Posts: 7,220
|
|
|
re: Force Display of Vertical Scroll Bars
This code is the cut down to exclude all the assignments of data I don't have.
It fills the textboxes with rubbish. Reporting linecount in the labels.
Just click the combo box and enter "a"
Code:
Private Sub idlookup_Change()
Me.taddinfo.Value = "ws.Range(engageid).Cells(Me.idlookup.ListIndex + 1, 1).Offset(0, 17)" & vbLf & _
"ws.Range(engageid).Cells(Me.idlookup.ListIndex + 1, 1).Offset(0, 17)" & vbLf & _
"ws.Range(engageid).Cells(Me.idlookup.ListIndex + 1, 1).Offset(0, 17)"
Me.taddresult.Value = "ws.Range(engageid).Cells(Me.idlookup.ListIndex + 1, 1).Offset(0, 19)" & vbLf & _
"ws.Range(engageid).Cells(Me.idlookup.ListIndex + 1, 1).Offset(0, 19)" & vbLf & _
"ws.Range(engageid).Cells(Me.idlookup.ListIndex + 1, 1).Offset(0, 19)" & vbLf & _
"ws.Range(engageid).Cells(Me.idlookup.ListIndex + 1, 1).Offset(0, 19)" & vbLf & _
"ws.Range(engageid).Cells(Me.idlookup.ListIndex + 1, 1).Offset(0, 19)"
With Me.taddresult
.SelStart = 0
.SetFocus
Label187.Caption = "Result/Update: [" & .LineCount & " lines]"
End With
With Me.taddinfo
.SelStart = 0
.SetFocus
Label186.Caption = "Information: [" & .LineCount & " lines]"
End With
End Sub
|

07-04-2009, 12:55 PM
|
|
Valued Forum Contributor
|
|
Join Date: 03 Jun 2008
Posts: 334
|
|
|
Re: Force Display of Vertical Scroll Bars
Thank you very much that will get me on the right track.
Thanks for your patience
|
 |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|