Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple UserForms not closing ceshelman[_4_] Excel Programming 0 June 22nd 06 11:13 PM
Multiple Identical UserForms Craig[_21_] Excel Programming 2 November 14th 05 06:03 AM
Multiple Userforms at once dok112[_32_] Excel Programming 0 October 7th 04 08:15 AM
Multiple Userforms open at once RockNRoll[_2_] Excel Programming 1 May 8th 04 11:10 PM
Multiple simultaneous macros and userforms Jex Excel Programming 3 April 27th 04 02:22 PM


All times are GMT +1. The time now is 05:05 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"