cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in oCombo.SelectExclusive

Former Member
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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.

Former Member
0 Kudos

Bryan,

Does it make sense to use the Combo without databinding ?

When I run it, The SelectExclusive returns no Error, and it actually selects the correct value on the form from within the valid values list.

The error occurs only on the Prd Line (oCombo.Selected), Each time.

Yuval.

Former Member
0 Kudos

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.

Former Member
0 Kudos

Bryan,

I have removed the DataBinding and it seems to work.

I will further look into it.

Thanks !

Yuval.

Answers (3)

Answers (3)

Former Member
0 Kudos

Have you tried it without the databinding?

Former Member
0 Kudos

Yuval, your query is probably returning no records. Trace it to make sure you actually have at least 1 record in oRS.

Former Member
0 Kudos

Hi,

The query returns two rows. It has been checked.

Yuval.

Former Member
0 Kudos

Yuval,

Dont use "SelectExclusive"

Use

oCombo.Select(0, SAPbouiCOM.BoSearchKey.psk_Index)

It will work fine.....

If it helps give reward points,

Regards,

Anitha

Former Member
0 Kudos

Anitha,

Thanks for the reply,

But as I mentioned, I have already tried this and the result was the same.

Other ideas ?

Yuval.

Former Member
0 Kudos

Hi,

please try replacing this line of code

Prd = oCombo.Selected.Value with

Prd = IIF(not oCombo.Selected is nothing,oCombo.Selected.Value." ")

Hope this helps

Regards

Vishnu

Former Member
0 Kudos

Hi,

I have tried your suggestion.

It produces the same result:

Same error occurs once the application runs over the oCombo.selected.

Yuval.