PDA

View Full Version : PROBLEM WITH SCROLL BOX INSIDE A FORM



Cheeco
02-13-2016, 04:24 PM
Hello all

I have inserted a scroll box into a user form and it is working however, when I open the form it will not allow me to insert anything into the scroll box. Why is this and how do I fix it?

Thank-you Cheeco

Paul_Hossler
02-13-2016, 05:26 PM
Hello all

I have inserted a scroll box into a user form and it is working however, when I open the form it will not allow me to insert anything into the scroll box. Why is this and how do I fix it?

Thank-you Cheeco

There's scrollbars and listboxes and comboboxes.

I'm not sure which you mean.

Cheeco
02-13-2016, 06:32 PM
The code I used is this and I placed in the user form code. Maybe I have it in the wrong place. I have attached a copy. The add, reset and close buttons I have not been able to get to work iether


Private Sub UserForm_Activate()
'Name of the frame
With Me.Frame2
'This will create a vertical scrollbar
.ScrollBars = fmScrollBarsVertical

'Change the values of 2 as Per your requirements
.ScrollHeight = .InsideHeight * 2
.ScrollWidth = .InsideWidth * 9
End With
End Sub

mikerickson
02-13-2016, 06:37 PM
Cross post
http://www.ozgrid.com/forum/showthread.php?t=198646
http://www.excelforum.com/excel-programming-vba-macros/1126828-scroll-box-problem-in-form.html

Cheeco
02-13-2016, 06:45 PM
Sorry Mikerickson. I for got about posting this Also posted at. It wont let me post the URL. It says something to do with forbidden words. I apologize that I broke the rules. Please tell me how I am suppose to add the other post URL.

Hoe come when I go to put in a web address it will not allow me to? Then I brake the rules by cross posting.

SamT
02-13-2016, 09:56 PM
You can leave the "http" off the address and it won't be a link

://www.vbaexpress.com

SamT
02-13-2016, 10:04 PM
FromHelp File

ScrollBar Control
Returns or sets the value of another control based on the position of the scroll box.
Remarks
A ScrollBar is a stand-alone control you can place on a form. It is visually like the scroll bar you see in certain objects such as a ListBox or the drop-down portion of a ComboBox. However, unlike the scroll bars in these examples, the stand-alone ScrollBar is not an integral part of any other control.
To use the ScrollBar to set or read the value of another control, you must write code for the ScrollBar's events and methods. For example, to use the ScrollBar to update the value of a TextBox, you can write code that reads the Value property of the ScrollBar and then sets the Value property of the TextBox.
The default property for a ScrollBar is the Value property.
The default event for a ScrollBar is the Change event.
Note To create a horizontal or vertical ScrollBar, drag the sizing handles of the ScrollBar horizontally or vertically on the form.



Frame Control
Creates a functional and visual control group (http://www.vbaexpress.com/forum/IDH_f3defControlGroup.htm).
Remarks
All option buttons in a Frame are mutually exclusive, so you can use the Frame to create an option group. You can also use a Frame to group controls with closely related contents.For example, in an application that processes customer orders, you might use a Frame to group the name, address, and account number of customers.
You can also use a Frame to create a group of toggle buttons, but the toggle buttons are not mutually exclusive.
The default event for a Frame is the Click event.

Paul_Hossler
02-14-2016, 07:57 AM
I'd just use a TextBox instead of a Frame and ScrollBar




Private Sub UserForm_Activate()
With Me.TextBox6
.MultiLine = True
.ScrollBars = fmScrollBarsVertical
End With
End Sub



15410

Only problem is that (right out of the box) to add anther line, you have to use Shift+Enter. Probably ways around that though

mikerickson
02-14-2016, 08:32 AM
We are getting a lot of duplication between sites.
The OP should pick one website, where the discussion will take place, and post in the other sites that the action is at that one chosen site.
It will save us from having to chase all over the internet and prevent us from duplicating each other's efforts.


Only problem is that (right out of the box) to add anther line, you have to use Shift+Enter. Probably ways around that though
The .MultiLine and .EnterKeyBehaviour properties of a text box will control that.
.MultiLine = True
.EnterKeyBehaviour = True, pressing Return enters a line-feed (vbLf) into the box,
.EnterKeyBehaviour = False, pressing Return sends the focus to the next control

Similarly the .TabKeyBehaviour property will control what the tab key does.

Paul_Hossler
02-14-2016, 08:51 AM
The .MultiLine and .EnterKeyBehaviour properties of a text box will control that.
.MultiLine = True
.EnterKeyBehaviour = True, pressing Return enters a line-feed (vbLf) into the box,
.EnterKeyBehaviour = False, pressing Return sends the focus to the next control

Similarly the .TabKeyBehaviour property will control what the tab key does


*&*(#%$!!^&^%% - I should have remembered that

That's what retirement does to you:igiveup:

SamT
02-14-2016, 08:55 AM
Looks like it was solved on mrexcel

This thread is closed