Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting item from a complex listbox

Status
Not open for further replies.

davefish

Technical User
Jul 26, 2002
169
GB
If anyone can help, I'd appreciate it! I have a userform which includes a listbox, a number of optionbuttons, a combobox and 20 checkboxes. The idea is to select a checkbox and then to place a number of variables against it in a 6 column list. On clicking ADD the data is displayed in the listbox. Then by clicking anther checkbox, you go through the whole shebang again and load the list with another set of values. I have succssfully catered for the option box logic but what's defying me is loading by each checkbox. Once this is sorted I need to be able to pass the data to another element be it an array or structure. Can anyone help. Here's my code so far:-

Dim DistArray(5, 3)

Private Sub Dp_Cmd_Add_Click()
Dim i As Single
Dim Dist1 As Integer
Dim Prot1 As String
Dim Com1 As String
Dim Pole As String
Dp_Lst_Rating.MultiSelect = fmMultiSelectMulti




MySettings.Dp_Cmb_Rating = Dp_Cmb_Rating
If Dp_Chk_Ow1 = True Then Dist1 = 1
If Dp_Opt_Fuse = True Then Prot1 = "Fuse" Else If Dp_Opt_Fuse = False Then Prot1 = "CB"
If Dp_Opt_Fuse = True Then Dp_Opt_Trip.Enabled = False And Dp_Opt_Ind.Enabled = False
If Dp_Opt_Fuse = True Then Dp_Opt_SPole.Enabled = False And Dp_Opt_DPole.Enabled = False
If Dp_Opt_Trip = True Then Com1 = "Trip" Else If Dp_Opt_Fuse = False Then Com1 = "Ind"
If Dp_Opt_SPole = True Then Pole = "Single" Else If Dp_Opt_SPole = False Then Pole = "Double"
Dp_Lst_Rating.ColumnCount = 5



DistArray(0, 0) = "Cct Number"
DistArray(1, 0) = "Rating"
DistArray(2, 0) = "Fuse/CB"
DistArray(3, 0) = "Trip/Ind"
DistArray(4, 0) = "Pole"


DistArray(0, 1) = Dist1
DistArray(1, 1) = MySettings.Dp_Cmb_Rating
DistArray(2, 1) = Prot1
DistArray(3, 1) = Com1
DistArray(4, 1) = Pole
DistArray(5, 1) = ""

DistArray(0, 2) = Dist1
DistArray(1, 2) = ""
DistArray(2, 2) = Prot1
DistArray(3, 2) = ""
DistArray(4, 2) = ""
DistArray(5, 2) = ""

Dp_Lst_Rating.Column() = DistArray




End Sub

Private Sub Dp_Cmd_Cancel_Click()
Unload frmDistribution_Parameters
End Sub


Private Sub Dp_Cmd_Ok_Click()


MySettings.Dp_Opt_Fuse = Dp_Opt_Fuse
MySettings.Dp_Opt_Cb = Dp_Opt_Cb
MySettings.Dp_Opt_Trip = Dp_Opt_Trip
MySettings.Dp_Opt_Ind = Dp_Opt_Ind
MySettings.Dp_Cmb_Rating = Dp_Cmb_Rating
MySettings.Dp_Chk_Ow1 = Dp_Chk_Ow1
MySettings.Dp_Chk_Ow2 = Dp_Chk_Ow2
MySettings.Dp_Opt_SPole = Dp_Opt_SPole
MySettings.Dp_Opt_DPole = Dp_Opt_DPole

Sheet1.Select

Unload frmDistribution_Parameters



End Sub

Private Sub Dp_Cmd_Clear_Click()
Unload frmDistribution_Parameters
frmDistribution_Parameters.Show

End Sub


Private Sub Dp_Cmd_Rem_Click()
Dp_Lst_Rating.RemoveItem (Dp_Lst_Rating.ListIndex)
End Sub

Private Sub Dp_Opt_Fuse_Click()
Dp_Opt_Cb.Enabled = False
Dp_Opt_Trip.Enabled = False
Dp_Opt_Ind.Enabled = False
Dp_Opt_SPole.Enabled = False
Dp_Opt_DPole.Enabled = False

End Sub


Private Sub UserForm_Initialize()
Dp_Cmb_Rating.RowSource = "DP_RATING"
Dp_Opt_Fuse.TripleState = True
Dp_Opt_Cb.TripleState = True
Dp_Opt_Trip.TripleState = True
Dp_Opt_Ind.TripleState = True

End Sub


DaveFish
 
Please rephrase exactly what you are trying to accomplish, and why it's not working, or what specifically you can't figure out. In the meantime, there are a few obvious problems in your code which I can help you with right now:

existing code:
If Dp_Chk_Ow1 = True Then Dist1 = 1
If Dp_Opt_Fuse = True Then Prot1 = "Fuse" Else If Dp_Opt_Fuse = False Then Prot1 = "CB"
If Dp_Opt_Fuse = True Then Dp_Opt_Trip.Enabled = False And Dp_Opt_Ind.Enabled = False
If Dp_Opt_Fuse = True Then Dp_Opt_SPole.Enabled = False And Dp_Opt_DPole.Enabled = False
If Dp_Opt_Trip = True Then Com1 = "Trip" Else If Dp_Opt_Fuse = False Then Com1 = "Ind"
If Dp_Opt_SPole = True Then Pole = "Single" Else If Dp_Opt_SPole = False Then Pole = "Double"

corrected code:

If Dp_Chk_Ow1 Then Dist1 = 1
If Dp_Opt_Fuse Then Prot1 = "Fuse" Else Prot1 = "CB"
If Dp_Opt_Fuse Then Dp_Opt_Trip.Enabled = False:Dp_Opt_Ind.Enabled = False
If Dp_Opt_Fuse Then Dp_Opt_SPole.Enabled = False:Dp_Opt_DPole.Enabled = False
If Dp_Opt_Trip Then Com1 = "Trip" Else Com1 = "Ind"
If Dp_Opt_SPole Then Pole = "Single" Else Pole = "Double"

The AND operator cannot be used to DO two things.
Also, the construct

if (boolean expression)=True then ...

makes my hair stand on end, even though it's extremely common. You don't need the =True!



Rob
[flowerface]
 
Hi Rob,

Thanks for getting back to me. I see what you mean re 'True', a good point I'll take forward.

I have 20 circuit configurations to load into a listbox and hence stored for later use in some sort of array. Assume that Cct 1 Checkbox Dp_Chk_ow1 is selected, I will then select a number of other boxes. for instance If fuse Dp_Chk_Fuse is selected it disables ALL the Circuit breaker(CB) functions checkboxes such as Dp_Chk_CB, Dp_Chk_Trip, Dp_Chk_Ind, Dp_Chk_SpOle & Dp_Chk_DPole.

When I click ADD it should load the check box value and the rating value into the listbox along with any selected Checkbox. Once this is loaded for Dp_Chk_ow1 I should then be able to load Dp_Chk_ow2 to the next listindex, but with different values. It's here where I'm getting stuck

Does this help at all?

DaveFish
 
Displaying the value of the Dp_Cmb_Ratings combobox and the a value for the checkboxes in the Listbox as follows:-

Dp_Chk_Fuse = String value as "Fuse"
Dp_Chk_Ind = String value as "Ind"

This is to show the configuration a customer selects.

Dave Fish
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top