Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Multiple Userforms Upon Click
I have the code working. Thank you for your assistance. Good show.
"Charles Chickering" wrote: I misunderstood what you wanted to do. I thought that you wanted to have multiple instances of the same userform. In your command button routine that searches through the checkboxes, put a conditional statement for "Checkbox8" and launch another userform if it is true: if ctl.caption = "Checkbox8" Then UserForm4.Show End If the initialize event for a userform only initialezes itself, however if you use something like UserForm4.Show inside of userform3_initialize, when the .Show method is used it triggers the .Initialize Event. -- Charles Chickering "A good example is twice the value of good advice." "Freddy" wrote: I am having trouble interpreting what you mean and placement of the code so below is sample code. By the way my primary and only form is named UserForm3. I have another form named UserForm1 which is used by a completely different and unrelated module. I do not have a UserForm2. Depending on which checkbox (A customer) is activated a corresponding subroutine is called. I also have 2 command buttons: #1 is to evaluate which checkboxes have been enabled, #2 is just to exit the code. What I would like to happen is during the evaluation that if, specifically, checkbox8 is enabled then a secondary userform (containing project names) appears with its own set of checkboxes related to the customer for checkbox8. Here you go... Private Sub UserForm_Initialize() CheckBox1.Caption = "Customer1" CheckBox2.Caption = "Customer2" CheckBox3.Caption = "Customer3" CheckBox4.Caption = "Customer4" CheckBox5.Caption = "Customer5€ CheckBox6.Caption = "Customer6€ CheckBox7.Caption = "Customer7" CheckBox8.Caption = "Customer8" CheckBox9.Caption = "Customer9" CheckBox10.Caption = "Customer10" CheckBox11.Caption = "Customer11" CheckBox12.Caption = " Customer12" CheckBox13.Caption = " Customer13" CheckBox14.Caption = " Customer14" CheckBox15.Caption = " Customer15" CheckBox16.Caption = " Customer16" End Sub 'This will evaluate all checkboxes then notify the user if all of them are unchecked: Private Sub CommandButton1_Click() Dim ctrl As Control Dim allOff As Boolean allOff = True For Each ctrl In UserForm3.Controls If TypeName(ctrl) = "CheckBox" Then If ctrl.Value = True Then allOff = False End If Next ctrl If allOff = True Then MsgBox "No customers were selected." 'Evaluate which reports to run. If CheckBox1.Value = True Then Call Customer1Subroutine If CheckBox2.Value = True Then Call Customer2Subroutine If CheckBox3.Value = True Then Call Customer3Subroutine If CheckBox4.Value = True Then Call Customer4Subroutine If CheckBox5.Value = True Then Call Customer5Subroutine If CheckBox6.Value = True Then Call Customer6Subroutine If CheckBox7.Value = True Then Call Customer7Subroutine If CheckBox8.Value = True Then Call Customer8Subroutine If CheckBox9.Value = True Then Call Customer9Subroutine If CheckBox10.Value = True Then Call Customer10Subroutine If CheckBox11.Value = True Then Call Customer11ubroutine If CheckBox12.Value = True Then Call Customer12Subroutine If CheckBox13.Value = True Then Call Customer13Subroutine If CheckBox14.Value = True Then Call Customer14Subroutine If CheckBox15.Value = True Then Call Customer15Subroutine If CheckBox16.Value = True Then Call Customer16Subroutine Application.StatusBar = False End Sub Private Sub CommandButton2_Click() End End Sub "Charles Chickering" wrote: The userform in VBA is basically a class module so just dim a couple of objects as the userform then try to call that objects .Show property, however I'm not sure if you can create an instance of a class module from itself. Here is the general idea assuming you userform is named Userform1: Dim MyForm As New UserForm1 MyForm.Show Private Sub MyCmd_Click() Dim MyForm2 As New UserForm1 MyForm2.Show End Sub Also all the previous code is going to be halted until the newest userform is closed, hopefully this is not an issue. -- Charles Chickering "A good example is twice the value of good advice." "Freddy" wrote: I have existing working code that displays a list of checkboxes and upon selection subroutines are run. However, I'd like to enhance the code so that if a particular checkbox is selected a 2nd userform is invoked with additional checkboxes. Does anyone have any suggestions? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Multiple UserForms not closing | Excel Programming | |||
Multiple Identical UserForms | Excel Programming | |||
Multiple Userforms at once | Excel Programming | |||
Multiple Userforms open at once | Excel Programming | |||
Multiple simultaneous macros and userforms | Excel Programming |