cancel
Showing results for 
Search instead for 
Did you mean: 

Clear UDO combo box

Former Member
0 Kudos

Hey All,

Can anyone tell me how I can clear the selected value from a combo box that is linked to a field on my UDO? even when the combo box has no valid values the previously selected value remains.

Thanks

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

I'm using 2004C and I'm fighting with the same problem:

I have a user form created from a UDO using cot_FormCreationParams.

On the form there are several ComboBox-s. In some cases I want to clear the ComboBox, so after actualizing the form the database field connected to it should be NULL.

I checked all the topics but I couldn't find the right solution.

First I tried this:

'// delete DataBound

Call oForm.Items(sDBItems(ii)).Specific.DataBind.SetBound(False)

'// Add an empty line

Call oForm.Items(sDBItems(ii)).Specific.ValidValues.Add("", "")

'// select the empty line

Call oForm.Items(sDBItems(ii)).Specific.Select(0, psk_Index)

'// clear valid values

For jj = oForm.Items(sDBItems(ii)).Specific.ValidValues.Count - 1 To 0 Step -1

Call oForm.Items(sDBItems(ii)).Specific.ValidValues.Remove(jj, psk_Index)

Next jj

'// set back the datasource

Call oForm.Items(sDBItems(ii)).Specific.DataBind.SetBound(True, sPrjTableName, sDBFieldNames(ii))

It looked fine for the first look. It showed nothing as selected on the form. But after pressing the Actualize button and recheck the record, it showed the old value: so I managed to achieve nothing.

I red the following advice: "YOU SHOULD CLEAR THE DATASOURCE RELATED TO IT"

Does it mean, I sould clear the whole user table from the form's DBDataSources? Should I use the DBDataSource.Clear()? But then all the data is lost from the form and I cannot get them back!

It's really strange that I have to fight so much to solve such a simple problem :-((

Thanks in advance,

Tamas

Former Member
0 Kudos

never mind... found the ocomb.select() method... thanks anyways!

Former Member
0 Kudos

Hello Trinidad:

Actually I have a question regarding the ComboBox. is there a way to preset a combo box on load? like when form load. All the combo box already have values. I couldn't find any properties on the help file or the demos. And I have been looking through the forum, but could't find any solution. You help is greatly appreciated! Thank You!

Former Member
0 Kudos

YOU SHOULD CLEAR THE DATASOURCE RELATED TO IT

Hagai

Former Member
0 Kudos

what is the datasource? I have a udo datasource for my table but I do not know how to clear that specific column drop down.

Trinidad
Product and Topic Expert
Product and Topic Expert
0 Kudos

Clearing the whole matrix datasource is not ok for you?

Regards

Trinidad.

Former Member
0 Kudos

Maybe I am not explaining this properly.

It is not a matrix datasource that I want to clear. I have a drop down list on my custom form that is not part of my matrix. It does not have a datasource assigned to it, I had valid values to the combo box from my code. Now when the user hits save on my form I want to clear the selection they have. But I do not want to put an empty valid value in the box and select that, I just want to clear the selection.

Trinidad
Product and Topic Expert
Product and Topic Expert
0 Kudos

You need to add a datasource where you will stock the value selected in the combo box. Then you can clear your datasource and it will clear the selected value in the combo box.

Regards

Trinidad.