cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mogulman
Level 8

Set Combobox Value

This should be simple.  I have a combobox (ClientContactCB) with a list of names.  One name is Ted Bell.  I have a variable, varClientContact = "Ted Bell".  I want to set the value of the combobox to the value of the variable "Ted Bell".

12 REPLIES 12
Microsoft dinusc
Microsoft

Re: Set Combobox Value

Hello mogulman,

What do you mean by "set the value fo the combobox"? Do you mean:

1. Changing the value of one of the ComboBox items?

2. Selecting that item in ComboBox?

 

For #1, you would have to change tha value on the source (form which the ComboBox is getting data)

For #2 For example:

Button1.OnSelect=Reset(ClientContactCB);Set(d, [varClientContact ])

ClientContactCB.DefaultSelectedItems=d

 

Clicking on Button1 should select the item from the variable varClientContact

mogulman52
Level: Powered On

Re: Set Combobox Value

I guess I'm not explaining myself very well. But I finally figured out problem.  DefaultSelectedItems expects a table.  Simply put square brackets around it to cast as table [varClientContact].  After I figured it out I looked dinusc's solution and noticed square brackets.  Wasted 2 hours on this.

 

Cast2Table.png

 

 

Microsoft dinusc
Microsoft

Re: Set Combobox Value

I'm glad you figured it out. Please note that the reason you need square brackets is because the DefaultSelectedItems can have more that one item.

NigelP
Level 8

Re: Set Combobox Value

Hi

 

How do I set the DefaultSelectedItems to the item the user has selected from the drop down ?

 

Regards

 

Nigel

NigelP
Level 8

Re: Set Combobox Value

Hi

 

I have tried this abd I get an error for combobox.DefaultSelectedItems saying that DefaultSlectedItems is an invalid name !

 

Anybody Any ideas ?

 

Regards

 

Nigel

mogulman
Level 8

Re: Set Combobox Value

How do I set the DefaultSelectedItems to the item the user has selected from the drop down ?

 

 I'm not understanding your question.  Do you have Dropdown and a Combobox?

 

To get value of Combobox selection use this:

 

Last(ClientContactCB.SelectedItems).FullName

ClientContactCB is the combobox.  FullName is the field in the combobox.  If this is not what you want post specific details on your question.

 

 

 

 

NigelP
Level 8

Re: Set Combobox Value

Hi Mogulman

 

I am trying to set a value for a combobox when a user selects a item from the dropdown.

 

Thanks

 

Nigel

Microsoft dinusc
Microsoft

Re: Set Combobox Value

Hello Nigel,

 

The following should work for default ComboBox1 and DropDown1 controls:

DropDown1.OnSelect=Reset(ComboBox1);Set(dsi,Dropdown1.Selected.Value)

ComboBox1.DefaultSelectedItems=[dsi]

NigelP
Level 8

Re: Set Combobox Value

Hi dinusc

 

This almost worked !

 

The selected value flashes up for a moment before "Find Items" overwrites it.

 

Regards

 

Nigel

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors
Users online (4,397)