Frames question

harper86

New Member
Joined
Nov 25, 2010
Messages
14
Hey
So I have a frame with 5 or 6 text boxes.
Right below this I have another frame with 5 or 6 more text boxes.
The thing I want to do is, if you are entering any text in any of the 5 or 6 text boxes the frame should change its background color to say red. Now if you go to the next frame the 1st frames bg color should go back to the original bg color and the second frames bg color should now be red.

This should also be true when you go back to frame 1.

Is there anyway to do this?

Also is there any way to change the bg color of the frame as soon as the text box becomes tabbed, like you have not input anything but the text box is selected.

Thank you very much
Hari
 
its a bit ironic that we all discuss the pro and cons of a mystery project whilst the person whose to benefit most, cant even be bothered to join in.

@MickG i had a great intro to class modules courtesy mikerickson, for which i have been eternally grateful. used it time and time again
 
Upvote 0

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Based on this criterion:
The thing I want to do is, if you are entering any text
The backcolor of a frame will only change when changing the text within a textbox.


UfmTest userform class module:
Code:
Private colTextBoxEvents As Collection
Private Sub UserForm_Initialize()
 
    Dim objControl As MSForms.Control
    Dim objTextBoxEvent As clsTextboxEvent
 
    Set colTextBoxEvents = New Collection
 
    For Each objControl In Me.Controls
        If TypeOf objControl Is MSForms.TextBox Then
            Set objTextBoxEvent = New clsTextboxEvent
            Set objTextBoxEvent.TextboxToCheck = objControl
            Set objTextBoxEvent.ParentUserform = Me
            colTextBoxEvents.Add objTextBoxEvent
        End If
    Next objControl
 
End Sub

clsTextboxEvent custom class module:
Code:
Private WithEvents pTbx As MSForms.TextBox
Private pUfm As MSForms.UserForm
 
Private Enum FrameFill
    Red = &HFF&
    Grey = &H80000004
End Enum
 
Private Sub pTbx_Change()
    Dim objControl As MSForms.Control
 
    For Each objControl In pUfm.Controls
 
        If objControl Is pTbx.Parent And TypeOf objControl Is MSForms.Frame Then
            pTbx.Parent.BackColor = FrameFill.Red
        ElseIf TypeOf objControl Is MSForms.Frame Then
            objControl.BackColor = FrameFill.Grey
        End If
 
    Next objControl
End Sub
 
Public Property Set TextboxToCheck(ByRef objTextBox As MSForms.TextBox)
    Set pTbx = objTextBox
End Property
 
Public Property Set ParentUserform(ByRef objUserForm As MSForms.UserForm)
    Set pUfm = objUserForm
End Property
 
Upvote 0
Hey
Again thank you for all the replies..
Colin Legg's method seems very interesting I shall try it out.
My userform is just a method for entering volumes and other information for different approaches, like NB, WB, SB and EB. So each frame captures the NB volumes and other infor and so on.
So technically what I wanted to do was if you were to tab out of the NB frame into the WB frame there should be some way to let the user know he is not entering NB volumes anymore visually. I was thinking along these lines.

Also I have another question, is there a way to set borders around a checkbox if the user tabs into it?
I mean I have 3 txtboxes and then a checkbox, so basically if he hits tab 4 times he has no way of knowing where in the form he is..Is there a way to set borders around the textbox as soon as he gets there?
 
Upvote 0
you could use a transperant label with a border, and set the .visible property
 
Upvote 0
At this point i feel kind of foolish...
James'W's code works perfectly fine..
Also I felt that instead of changing the bg color a altering hte spc effect woul be a slightly better

Private Sub fraNBVol_Enter()
fraNBVol.SpecialEffect = fmSpecialEffectRaised
fraWBVol.SpecialEffect = 0
fraSBVol.SpecialEffect = 0
End Sub

Private Sub fraWBVol_Enter()
fraWBVol.SpecialEffect = fmSpecialEffectRaised
fraNBVol.SpecialEffect = 0
fraSBVol.SpecialEffect = 0
End Sub

I feel like an idiot...Thank you very much..
 
Upvote 0
But you cant click on the checkbox anymore because of the label.
I guess Ill just have to change the background color or something
 
Upvote 0
bring the checkbox to the front
select checkbox format>order>bring to front
 
Upvote 0
Oh okay that would work..
Thank you..
And we would set the bordercolor to black in what event procedure?
chkbox_enter?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,077
Messages
6,128,685
Members
449,463
Latest member
Jojomen56

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