cancel
Showing results for 
Search instead for 
Did you mean: 

Populating combobox in user form

Former Member
0 Kudos

Hi,

I have a combobox on my user defined form.

I want to poputate month names in it when it opens up.

How can i do that?

Thanks.

Satish.

Accepted Solutions (1)

Accepted Solutions (1)

barend_morkel2
Active Contributor
0 Kudos

on the form load event:

Dim ocmbo As SAPbouiCOM.ComboBox

ocmbo = SBO_App.Forms.Item(FormUID).Items.Item("YourComboID").Specific

ocmbo.ValidValues.Add("1", "January")

ocmbo.ValidValues.Add("2", "February")

etc...

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi,

I think that this cannot be done in the form load event.

So i solved this problem in the menu event.

When my user defined menu is clicked, i first load my form and then populate the combobox.

I have a little different question.I want to use a user data source to populate this combo box with month names.

How can i do that.Can you provide a sample.

Thanks.

Former Member
0 Kudos

In VB there is a locals window where you can see objects and there properties.

The object "frm" which is my form does not show any item(that is my combo box, matrix ok button and cancel button)

It seems like during form load, combo box, matrix and other items are not yet added to form.

Are you able to set the combo box values during form load of your user defined form?

Former Member
0 Kudos

Hi,

I am using VB6.

And after these lines

If pVal.EventType = et_FORM_LOAD And pVal.Before_Action = False Then

Set frm = applic.Forms.Item(FormUID)

when i see the local window, there are no items listed under object frm.

AlexGrebennikov
Active Contributor
0 Kudos

could you be more specific, plz.

what does <i>'no items listed under object frm'</i> meen?

Former Member
0 Kudos

Hi,

Yes i am passing the correct UID(case sensitive) for the combobox which is "U_CbMt".

This userdefined field is on my form and is not deriving values from any table.

I am trying to populate the combobox in my user defined form load event.

I think(correct me if i am wrong) that during form load, the items are not created on the form yet.That is why it cannot find my item.

If this is true, how else can i populate my combobox?

Thanks.

AlexGrebennikov
Active Contributor
0 Kudos

Satich, do you really can get access to frm.Items.Item("U_CbMt").Specific.ValidValues-property?!

what development language are you usin'?

try that lines:

If pVal.EventType = et_FORM_LOAD And pVal.Before_Action = False Then
Set frm = applic.Forms.Item(FormUID)
Set <b>oCombo</b> = frm.Items.Item("U_CbMt").Specific
<b>oCombo</b>.ValidValues.Add "Jan", "January"

where oCombo is SAPbouiCOM.ComboBox

Former Member
0 Kudos

Hi Barend,

I do the following :

If pVal.EventType = et_FORM_LOAD And pVal.Before_Action = False Then

Set frm = applic.Forms.Item(FormUID)

frm.Items.Item("U_CbMt").Specific.ValidValues.Add "Jan", "January"

End If

It gives me an error saying Invalid Item.

Former Member
0 Kudos

Are you sure your combo box's UID is "U_CbMt"?

Former Member
0 Kudos

Satish,

Does "U_CbMt" mean that you are specifying VVs for a UDF? If yes, the why not specify them in the Tools / User-Defined Fields / etc...?

Also, if the UDF item resides with other UDFs on a 'UDF form '( accessible through shiftctrl-U), then you should use -frm.Type as form type to get the UDF-form.

HTH

Juha

barend_morkel2
Active Contributor
0 Kudos

The UID of your combobox is case specific