cancel
Showing results for 
Search instead for 
Did you mean: 

Loading combo box with text box values

Former Member
0 Kudos

Hi All,

i am having a combo box and a text box...Combo box is already loaded with some static values.If i am entering any data in the text box and if i am clicking the add button, that data should also be loaded in that combo box....How to do this...?

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member196647
Contributor
0 Kudos

In the click event of the button, add this code

dim textvalue as string

textvalue = oform.items(itemnumber).specific.value

ocombobox.validvalues.add(textvalue, textvalue)

itemnumber is the uniqueid of the text box and ocombobox is the reference to the combo box.

Rahul

Former Member
0 Kudos

Hi Rahul,

Thanks for your response..Your code works fine..But, what my issue is whenever i stop the addon and run it once again means, the value which i had loaded from textbox to combo box got cleared...Only the values which i had given as validvalues remains in the combo box.....

former_member196647
Contributor
0 Kudos

Please check if during the start up of the add-on the combo box is defined and/or the valid values are cleared and than defined again.

If it is so, than it is normal for the values which you've added during the runtime to be cleared on the startup.

Rahul

Former Member
0 Kudos

HI Rahul,

I had loaded the combo box with validvalues (which, i had already given in XML). Other than that, i want to load the combo box with the values which i had given in the text box. (Validvalues + Textbox values). By using your code, the value which i had given in textbox got added in the combo box. but when i close that screen and opens it once again means, only the valid vales which i had given in XML remains in the combo box. The values which got added through the textbox is not available in the combo box....This is my issue....

former_member196647
Contributor
0 Kudos

That's correct. It will not have the values you loaded from the text box, because those values are not saved any where else.

There are 2 options, one you can create a table, and add the values there. This way, at the time of loading the form, create a procedure to load the values from the table into the combo box valid values.

Second, you can save the values in a text file and load them from there, using basic file handling functions of vb.

The first one will be easier and more robust though. When some values are added in the text box, you can simply add a new row in the table, with the new value.

Rahul

Former Member
0 Kudos

Hi Rahul,

Thanks a lot...I'll work it out and tell....