ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Could not set the Text property of a ComboBox on User Form. (https://www.excelbanter.com/excel-programming/379220-re-could-not-set-text-property-combobox-user-form.html)

NickHK

Could not set the Text property of a ComboBox on User Form.
 
What is combo box's .Style set to ?
If it is 2-List, change to 0-Combo.

NickhK

"??????? ?. ???????" wrote in message
...
The statement
ComboBox1.Text = "1,2,3"
yields to a run-time error. The ComboBox1.MatchEntry is fmMatchEntryNone,
and ComboBox1.MatchRequired is False . The "1,2,3" does not match any

entry
in the ComboBox1 at the time, but I want to show it in the edit field of

the
combo box.




NickHK

Could not set the Text property of a ComboBox on User Form.
 
Yes, that means you cannot set .Text to a value that is not in the list.

NickHK

"??????? ?. ???????" wrote in message
...
ComboBox1.Style equals to fmStyleDropDownList

"NickHK" ?????:

What is combo box's .Style set to ?
If it is 2-List, change to 0-Combo.

NickhK

"??????? ?. ???????" wrote in message
...
The statement
ComboBox1.Text = "1,2,3"
yields to a run-time error. The ComboBox1.MatchEntry is

fmMatchEntryNone,
and ComboBox1.MatchRequired is False . The "1,2,3" does not match any

entry
in the ComboBox1 at the time, but I want to show it in the edit field

of
the
combo box.







NickHK

Could not set the Text property of a ComboBox on User Form.
 
Well this code errors as expected in my version of Excel 2002 :

Private Sub UserForm_Initialize()
With ComboBox1
.Style = fmStyleDropDownList
.AddItem "Item 1"
.AddItem "Item 2"
.AddItem "Item 3"
.AddItem "Item 4"

.Text = "Not in list"
End With
End Sub

but this not not :

Private Sub UserForm_Initialize()
With ComboBox1
.Style = fmStyleDropDownCombo
.AddItem "Item 1"
.AddItem "Item 2"
.AddItem "Item 3"
.AddItem "Item 4"

.Text = "Not in list"
End With
End Sub

Read the help on the .Style property.

NickHK

"??????? ?. ???????" wrote in message
...
Why? The ComboBox1.MatchEntry is fmMatchEntryNone, and
ComboBox1.MatchRequired is False. And it works fine in the Office 2002.

And
what You do suggest?

"NickHK" ?????:

Yes, that means you cannot set .Text to a value that is not in the list.

NickHK

"??????? ?. ???????" wrote in message
...
ComboBox1.Style equals to fmStyleDropDownList

"NickHK" ?????:

What is combo box's .Style set to ?
If it is 2-List, change to 0-Combo.

NickhK

"??????? ?. ???????" wrote in message
...
The statement
ComboBox1.Text = "1,2,3"
yields to a run-time error. The ComboBox1.MatchEntry is

fmMatchEntryNone,
and ComboBox1.MatchRequired is False . The "1,2,3" does not match

any
entry
in the ComboBox1 at the time, but I want to show it in the edit

field of
the
combo box.






All times are GMT +1. The time now is 08:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com