Error In Assigning A Combobox Value To A Variable value

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,564
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
This I'm sure is a simple problem to resolve, but it's eluding me.

Code:
UserForm1.uf1cbx1_operatorini.Value = sgini

uf1cbx1_operatorini is a combobox with a series of 6 selectable values. If the value does not exist in the list, the user can select "other" from the list prompting them with an input box to enter a value (sgini).
When the code reaches the line above, it breaks with error "Could not set the Value property. Invalid property value."

Is anyone able to suggest what might be a cause of this error? I have been thinking it might have something to do with the fact that the value represented by variable sgini isn't in the rowsource of the combobox. If so, is there a way I can bypass this limitation?
 
I don't know whether I'll be able to help either, but when the code errors out on that line what value has been assigned to the variable sgini?
 
Upvote 0

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Hi Domenic, the value of sigini is what is expected. Basically, what sgini is the initials of the name provided by the user in the uf1lbl1_name textbox (see code in post 8).

With some testing, I discovered that I can succesfully populate the uf1cbx1_operatorini combobox with that erroneous line of code by substituting 'gsini' with "", or any value in the dropdown list, ie "BK" ... one of the 8 available selections from the combobox. Any other value than these results in an error.

I discovered also, that I can populate other comboboxes and textboxes on this userform by assigning them the value of 'sgini'. So clearly, it's an issue specific to the uf1cbx1_operatorini combobox.

Behavior Properties:
Autosize : False
Autotab : False
AutoWordSelect : True
Enabled : True
HideSelection : True
Locked : False
MatchEntry : 0 - fmMatchEntryFirstLetter
MatchRequired : False
MaxLength : 0
SelectionMargin : True
TextAlign : 2 - fmTextAlignCenter

Data Properties:
BoundColumn : 1
ColumnCount : 1
CoulumnHeads : False
ColumnWidths :
ControlSource :
ListRows : 4
ListStyle : 0 - fmListStylePlain
ListWidth : 0 pt
Rowsource :
Text :
TextColumn : -1
TopIndex : -1
 
Last edited:
Upvote 0
What if you try this
Code:
UserForm1.uf1cbx1_operatorini.AddItem sgini
UserForm1.uf1cbx1_operatorini.Value = sgini
 
Upvote 0
Basically, what sgini is the initials of the name provided by the user in the uf1lbl1_name textbox

Yes, but what does sgini actual hold when that line errors out?
 
Upvote 0
Brilliant!!
Just what I needed, thank you!!

Thats awesome now to get me to my next challenge.
 
Last edited:
Upvote 0
You're welcome, although I don't understand why it needs that line.
 
Upvote 0
That's interesting, it will only accept a value that exists within its list of items, yet MatchRequired is set to False. Oh well, in any case, Fluff has given you a solution, so that's great.

Cheers!
 
Upvote 0
Actually, I had one other thought. Maybe, while MatchRequired is set to False when you look under the Properties window, it gets set to True when the code runs, maybe within the initialize event. Anyway, just a thought.
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,276
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top