cancel
Showing results for 
Search instead for 
Did you mean: 

ComboBox with BusinessPartners

Former Member
0 Kudos

An apology for my English, I'm trying to do a comboBox filled with my Business Partners names and codes, but I can't.

I Modify part of the examples and this is the code that I use:


SAPbobsCOM.BusinessPartners oBusinessPartner;
SAPbobsCOM.Recordset oRecordSet;

oRecordSet = (SAPbobsCOM.Recordset) SAPConn.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);

oBusinessPartner = (SAPbobsCOM.BusinessPartners) SAPConn.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBusinessPartners);

try
{
   Combo1.Items.Clear();

   while (!(oRecordSet.EoF == true))
   {
      oBusinessPartner.GetByKey(oRecordSet.Fields.Item(0).Value.ToString());
      Combo1.Items.Add(oBusinessPartner.CardCode);

      oRecordSet.MoveNext();
   }
}
catch (Exception ex)
{
   MessageBox.Show(ex.ToString());
}

Edited by: gaestudio on Jun 25, 2010 9:17 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

The way you have written code to get the Business Partners is not correct. You should bind both value and description to combobox. Use this below code.

DimoComboBox As SAPbouiCOM.ComboBox
Dim RS As SAPbobsCOM.Recordset       

        RS = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)     

        RS.DoQuery("SELECT T0.[CardCode], T0.[CardName] FROM OCRD T0")

        RS.MoveFirst()
        While RS.EoF = False
            oComboBox.ValidValues.Add(RS.Fields.Item("CardCode").Value, RS.Fields.Item("CardName").Value)
            RS.MoveNext()
        End While

Note:Your combobox should be bound with datasource

Regards,

Noor Hussain

Answers (0)