on 11-14-2007 12:26 PM
Hi,
I am trying to use a value in a combobox.
This is the code I use:
-
<i>oCombo = oForm.Items.Item("CmbPrd").Specific
oCombo.DataBind.SetBound(True, "", "CmbPrd")
oRS.DoQuery("SELECT T0.Code, T0.Name FROM OFPR T0")
For ii = 0 To oRS.RecordCount - 1
oCombo.ValidValues.Add(oRS.Fields.Item(0).Value, oRS.Fields.Item(1).Value)
oRS.MoveNext()
Next ii
oCombo.SelectExclusive(0, SAPbouiCOM.BoSearchKey.psk_Index)
Prd = oCombo.Selected.Value</i>
-
when trying to do the last line, I get:
"Object reference not set to an instance of an object" Error.
ocombo.selected has a value of nothing.
I have tried using the 'Select' method instead of 'SelectExclusive' and it still doesnt work.
I am using 2005A SP01.
I think it used to work on previous versions.
Am I doing something wrong ? Anyone has an idea ?
Thanks,
Yuval.
Yuval, when I test this, the only time I can get it to generate that error and for oCombo.Selected to be nothing is when oCombo has no ValueValues in it.
But the error occurs on the SelectExclusive() line. It never makes it to the Prd line. If oCombo has no ValidValues, it should be impossible to ever make it past the line.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I never use databinding. Ever. I'd rather have control over reading/writing data than to faithfully rely on some mysterious black box that you can't touch.
I would first try turning off the databinding to see if it's causing a problem.
It sounds like when you're doing the select that something's happening that's causing the value to be de-selected. I'd check to see if something's happening in the Combo_Select event on the form that might not be trapping an error or it's clearing your selection for some reason.
Are you positive that oCombo.Selected is nothing? If it has something in it, then Prd may be the problem.
Have you tried it without the databinding?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yuval, your query is probably returning no records. Trace it to make sure you actually have at least 1 record in oRS.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yuval,
Dont use "SelectExclusive"
Use
oCombo.Select(0, SAPbouiCOM.BoSearchKey.psk_Index)
It will work fine.....
If it helps give reward points,
Regards,
Anitha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
108 | |
12 | |
11 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.