cancel
Showing results for 
Search instead for 
Did you mean: 

Bind Data From Data Base to COmbo Box

Former Member
0 Kudos

Private Sub CreateFormsIncentives()

oItem = oForm.Items.Add("lblInName", SAPbouiCOM.BoFormItemTypes.it_STATIC)

oItem.Left = 7

oItem.Width = 160

oItem.Top = 15

oItem.Height = 14

oItem.LinkTo = "cbInName"

oStaticText = oItem.Specific

oStaticText.Caption = "Incentive Name Options"

'' //Add a edit text item

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

oItem.Left = 65

oItem.Width = 148

oItem.Top = 32

oItem.Height = 14

oItem.LinkTo = "lblInName"

oComboBox = oItem.Specific

oComboBox.DataBind.SetBound(True, "@TBLINCENTIVE", "U_Combobox")

'oForm.DataSources.UserDataSources.Add("cbInName", SAPbouiCOM.BoDataType.dt_SHORT_TEXT, 10)

End Sub

'Here is the Code FORM_LOAD

If pVal.FormType = "Incentive" And pVal.BeforeAction = False And pVal.EventType = SAPbouiCOM.BoEventTypes.et_FORM_LOAD Then

Try

Dim oRecordSet As SAPbobsCOM.Recordset

' Dim Bob As SAPbobsCOM.SBObob

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

oRecordSet.DoQuery("select U_IncName from dbo.[@INC] ORDER BY U_IncName")

Dim getnum As Long

getnum = oRecordSet.RecordCount

oCombo = OForm.Items.Item("cbInName").Specific

Do Until oRecordSet.EoF = True

'// add the value of the first field of the Recordset

oCombo.Items.Add(oRecordSet.Fields.Item(0).Value, oRecordSet.Fields.Item(0).Name)

'// move the record pointer to the next row

oRecordSet.MoveNext()

Loop

If oCombo.Items.Count > 0 Then

oCombo.SelectedIndex = 0

End If

Catch ex As Exception

SBO_Application.StatusBar.SetText(ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error)

End Try

End If

Pls,Help me,

Thanks,

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member187989
Active Contributor
0 Kudos

hi,

Pl post question in SAP Business One SDK forum to get quick responses.

Jeyakanthan