Skip to Content
0
Feb 09, 2015 at 09:53 AM

How to populate a combo box with the results of a query?

593 Views

Hi,

I want to populate a simple combo box with the results of a simple query. There are many threads on the forum, but I am confused.

My code is below, How to make it work?

Thanks

Leon Lai

'==============================================

'//ADD FORM

'==============================================

oForm = SBO_Application.Forms.AddEx(oFrmParam)

'==============================================

'//Set form width and height

'==============================================

oForm.Height = 200

oForm.Width = 250

oForm.Title = "Test For Combo "

'==============================================

'//Create A User Data Source

'==============================================

userDS = oForm.DataSources.UserDataSources.Add("Project", SAPbouiCOM.BoDataType.dt_SHORT_TEXT, 30)

''//*************************

''// Adding a Combo Box item

'//*************************

oItem = oForm.Items.Add("ComboBox1", SAPbouiCOM.BoFormItemTypes.it_COMBO_BOX)

oItem.Left = 20

oItem.Width = 150

oItem.Top = 80

oItem.Height = 20

oCmbBox = oItem.Specific

oCmbBox.DataBind.SetBound(True, " ", "Project")

Dim oRecordSet As SAPbobsCOM.Recordset

Dim StrQuery As String

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

StrQuery = "Select DISTINCT T1. PrjCode, T1.PrjName from OPRJ T1 "

oRecordSet.DoQuery(StrQuery)

For i As Integer = 1 To oRecordSet.RecordCount

'???????????

'???????????

Next