on 12-13-2011 5:01 AM
Hi Experts, please check my code.
In my ItemEvent.
When I try to changed the value of my Combobox then messagebox will show and display the current value of my combobox. But there's a error Object reference not set to an instance of an object.
Try
Select Case pVal.Action_Success
Case False
Case True
Select Case pVal.EventType
Case SAPbouiCOM.BoEventTypes.et_FORM_LOAD
'If pVal.FormType = 2000060006 Then
Call AddItemCodeCombo()
'End If
Case SAPbouiCOM.BoEventTypes.et_CLICK
Select Case pVal.ItemUID
Case "cmdSave"
End Select
Case SAPbouiCOM.BoEventTypes.et_COMBO_SELECT And pVal.Before_Action = False
Select Case pVal.ItemUID
Case "cFrom"
oItem = oForm.Items.Item("cFrom")
Dim oCombo As SAPbouiCOM.ComboBox ' = oForm.Items.Item("cFrom")
oCombo = oItem.Specific
SBO_Application.MessageBox(oCombo.Selected.Value)
End Select
End Select
End Select
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
And this code is to fill my combobox.
Sub AddItemCodeCombo()
Dim oCompany As SAPbobsCOM.Company = SBO_Application.Company.GetDICompany
Dim RS As SAPbobsCOM.Recordset
Dim oCombo As SAPbouiCOM.ComboBox = oForm.Items.Item("cFrom").Specific
Try
If oCombo.ValidValues.Count > 0 Then
For i As Integer = 0 To oCombo.ValidValues.Count - 1
oCombo.ValidValues.Remove(0, SAPbouiCOM.BoSearchKey.psk_Index)
Next
End If
RS = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
RS.DoQuery("SELECT dbName, cmpName FROM [SBO-COMMON].dbo.SRGC")
'RS.MoveFirst()
'If RS.RecordCount > 0 Then
Do While Not RS.EoF
oCombo.ValidValues.Add(RS.Fields.Item(0).Value.ToString, RS.Fields.Item(1).Value.ToString)
RS.MoveNext()
Loop
'End If
oCombo.Select(0, SAPbouiCOM.BoSearchKey.psk_Index)
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
RS = Nothing
End Try
End Sub
Please help me with this.
Thank you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello
Propably nothing is selected in you combobox, try the following code
if oCombo.Selected isNot Nohting then
SBO_Application.MessageBox(oCombo.Selected.Value)
else
'nothing selected
endif
Object not set becasue of oCombo.Selected is a validvalue object.
Regards
János
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Select Case pVal.ItemUID
Case "cFrom"
oItem = oForm.Items.Item("cFrom")
Dim oCombo As SAPbouiCOM.ComboBox ' = oForm.Items.Item("cFrom")
oCombo = oItem.Specific
If oCombo.Selected IsNot Nothing Then
SBO_Application.MessageBox(oCombo.Selected.Value)
Else
'nothing selected
End If
End Select
I try this but no luck.
User | Count |
---|---|
100 | |
11 | |
10 | |
6 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.