View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Toppers Toppers is offline
external usenet poster
 
Posts: 4,339
Default Still Having Trouble with Combo Box

Hi,
I ran your code as posted and only problem(s) I found was that the
macros Combobox2A_Click (and 2B,2C) were missing - these are actioned when
you select from the second combobox - so I just added these as below and
everything worked. I was puzzled by the If optmeasureE.Value = True
statement (how is 'optmeasureE' defined?) so I improvised.

If you continue to have problems, post me the workbook and explain the
)

Sub Combobox2A_Click()
MsgBox "Combobox2A_Click called"
End Sub


"mtm4300 via OfficeKB.com" wrote:

I hate to be a pest, but I am still having trouble executing this process.
There are several errors that occur. Here is the code I have. I didnt put the
optmeasureM code here, because it will almost be the same as the optmeasureE
code. If anyone could try to run this and help me figure the problems, I
would greatly appreciate it. Thank you. Also the name of my worksheet is
'Program'

Sub optmeasureE_Click()

' Determines if the user executes the program in English units.

If optmeasureE.Value = True Then
CreateCombobox1
End If

End Sub
Sub optmeasureM_Click()
CreateCombobox3

' Determines if the user executes the program in Metric units.

If optmeasureM.Value = True Then

End If

End Sub

Sub CreateCombobox1()
Dim newname As Worksheet
Set newname = Sheets("Program")

With Worksheets(1).Shapes.AddFormControl(xlDropDown, _
Left:=245, Top:=189.75, Width:=192, Height:=15)
.ControlFormat.DropDownLines = 3
.ControlFormat.AddItem "E1: Mainline or Public Road Approach", 1
.ControlFormat.AddItem "E2: Drive, Including Class V", 2
.ControlFormat.AddItem "E3: Median/Mainline or Public Road Approach*", 3
.Name = "Combobox1"
.OnAction = "Combobox1_Change"

End With
End Sub
Sub Combobox1_Change()

Dim idex As Long
Dim newname As Worksheet
Set newname = Sheets("Program")

On Error Resume Next
Worksheets(1).DropDowns("Combobox2").Delete
On Error GoTo 0

idex = Worksheets(1).DropDowns("Combobox1").ListIndex
With Worksheets(1).Shapes.AddFormControl(xlDropDown, _
Left:=245, Top:=309, Width:=192, Height:=15)
.ControlFormat.DropDownLines = 7
.Name = "Combobox2"

Select Case idex

Case 1
.ControlFormat.AddItem "E1: Circular Corrugated Pipe", 1
.ControlFormat.AddItem "E1: Circular Corrugated Pipe (SPM)", 2
.ControlFormat.AddItem "E1: Circular Smooth-Interior Pipe", 3
.ControlFormat.AddItem "E1: Deformed Corrugated Pipe", 4
.ControlFormat.AddItem "E1: Deformed Corrugated Pipe (SPAA)", 5
.ControlFormat.AddItem "E1: Deformed Corrugated PIpe (SPS)", 6
.ControlFormat.AddItem "E1: Deformed Smooth-Interior Pipe", 7
.OnAction = "Combobox2A_Click"

Case 2
.ControlFormat.AddItem "E2: Circular Corrugated Pipe", 1
.ControlFormat.AddItem "E2: Circular Corrugated Pipe (SPM)", 2
.ControlFormat.AddItem "E2: Circular Smooth-Interior Pipe", 3
.ControlFormat.AddItem "E2: Deformed Corrugated Pipe", 4
.ControlFormat.AddItem "E2: Deformed Corrugated Pipe (SPAA)", 5
.ControlFormat.AddItem "E2: Deformed Corrugated PIpe (SPS)", 6
.ControlFormat.AddItem "E2: Deformed Smooth-Interior Pipe", 7
.OnAction = "Combobox2B_Click"

Case 3
.ControlFormat.AddItem "E3: Circular Corrugated Pipe", 1
.ControlFormat.AddItem "E3: Circular Corrugated Pipe (SPM)", 2
.ControlFormat.AddItem "E3: Circular Smooth-Interior Pipe", 3
.ControlFormat.AddItem "E3: Deformed Corrugated Pipe", 4
.ControlFormat.AddItem "E3: Deformed Corrugated Pipe (SPAA)", 5
.ControlFormat.AddItem "E3: Deformed Corrugated PIpe (SPS)", 6
.ControlFormat.AddItem "E3: Deformed Smooth-Interior Pipe", 7
.OnAction = "Combobox2C_Click"

End Select
End With

End Sub

Toppers wrote:
Hi,
This suggests you are trying to create a combobox (CreateAMajor?) which
already exists. Add code to delete as per Tom's example for "cboCoice" ...
typo ? cboChoice?
.... but once created should it not remain until worksheet closes?

Tom O. helped me with a problem I had creating a varying combo box. I used
the code, but I am still having errors. The purpose of the program is to

[quoted text clipped - 85 lines]

End Sub


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200602/1