PDA

View Full Version : uneditable comboboxes



white_flag
04-13-2010, 01:36 AM
good morning,

Question:It is an possiblity to protect comboboxes, to become uneditable, but still to have the drop down list?

thx

GTO
04-13-2010, 04:58 AM
Change the .Style property to fmStyleDropDownList

white_flag
04-13-2010, 07:13 AM
thx for answer. now if the following error:

Could not set the Value propriety. Invalid property value. (logic because)
ComboBox9.Value = Rng(11) .. how can I put an logical statement that can initzialized the first value from combobox list if the value is not equal or is missing

GTO
04-13-2010, 11:16 AM
Hi white_flag,

I am afraid that your question is not making sense to me. Please attach a small example workbook with the combobox and the code as is; that is, to show how you are currently trying to add value(s) to it, and from whence the vals came.

Thanks,

Mark

white_flag
04-14-2010, 12:06 AM
correct ..mia culpa.
Please look in attach. It talks better then me.

GTO
04-14-2010, 04:07 AM
Hi there,

I doubt that I'll be of much help, but if I can be a little help, and one of the guys can come by and rescue us, that would be great. Here is what I observed:


thx for answer. now if the following error:

Could not set the Value propriety. Invalid property value. (logic because)

ComboBox9.Value = Rng(11) ..

I do not see the above anywhere in the code. That said, I did find where the value of ComboBox9 was (attempted) assigned to "Rng(11)".

Presuming that you included all the code, I do not see where 'Rng()' is declared or sized?


how can I put an logical statement that can initzialized the first value from combobox list if the value is not equal or is missing

I am afraid that with not understanding how the array could work at this point, this part is just beyond me :-(

I hope you get some great help, or can say whether CommandButton12 (click) runs for you if there is missing code or something that I am just not getting. The userform seems very neat :thumb to me; I really like how you have it changing languages!

Sorry I cannot help thus far,

Mark

white_flag
04-14-2010, 04:55 AM
thx, Mark

for me I would like to put an deviation from error.
Like: if error, initialized combobox with first value from list ..etc

mdmackillop
04-14-2010, 05:55 AM
I think you need to find the item in the Combo and change the ListIndex to suit


Private Sub ListBox1_Click()
Insul = ListBox1
Set Rng = Rows(2).Find(Insul, LookAt:=xlWhole).resize(1)
TextBox1.Value = Rng(1) 'name
TextBox2.Value = Rng(2) 'diametru
TextBox4.Value = Rng(3) 'Lenght Body
ComboBox6.Text = Rng(4) 'Insulation Body
ComboBox7.Value = Rng(5) 'tk Insulation Body
TextBox9.Text = Rng(6) 'Layer Insulation Body
ComboBox8.Text = Rng(10) 'Type Sheeting Body
'Change here
ComboBox9.ListIndex = LIndex(ComboBox9, Rng(11)) 'tk Sheeting Body
'............

Function LIndex(Ctrl As Control, v)
Dim i As Long
For i = 0 To Ctrl.ListCount
If v = --Ctrl.List(i) Then
LIndex = I
Exit Function
End If
Next
End Function

white_flag
04-14-2010, 06:21 AM
with: If v = --Ctrl.List(i) Then I have this error: Error 13 - Type mismatch

with: If v = Ctrl.List(i) Then I have this error: Error 381 - Could not get the list property. invalid property array index

mdmackillop
04-14-2010, 06:27 AM
The values in the combos and theRng(11) etc. need to be comparable.
-- was to convert 0.6 string to numerical. You may need to play around with these to get it to work.

white_flag
04-14-2010, 06:42 AM
ok :) thx ..but before you go from this thread. I have one more question that you help me in an different thread. how can I delete the first two rows from the listbox without having an error. Like this to have an empty file without any data inserted in worksheet

mdmackillop
04-14-2010, 07:37 AM
Read the items into an array, clear the box then add them back, omitting the first two.

white_flag
04-14-2010, 09:23 AM
ok ..I am so lost ..can you be more precise? I would like to fix this alone, but I can not ..

mdmackillop
04-14-2010, 10:12 AM
Sub LoseFirst()
Call NewList(ComboBox9, 2)
End Sub

Sub NewList(Ctrl As Control, ToLose As Long)
Dim i As Long
Dim arr()
ReDim arr(Ctrl.ListCount - ToLose - 1)
For i = 0 To Ctrl.ListCount - ToLose - 1
arr(i) = Ctrl.List(i + ToLose)
Next
Ctrl.Clear
Ctrl.List() = arr
End Sub

white_flag
04-14-2010, 11:59 AM
thx for help ..but this is to much for me.I have to search for an simple solution

white_flag
04-15-2010, 05:49 AM
in attachment is an simplify version ..maybe someone will help me

white_flag
04-16-2010, 06:10 AM
.. I would like here a bit of magic ..

white_flag
04-19-2010, 02:06 PM
good evening
I need your help if it is possible.
I change the "tactic" but I am stuck (again). I change the list box in listview. now, I do not know how to delete an filed or to edit an field and initialized an listview. I would appreciated any help. thank you (please look in attachment).