Listbox-problem

  • Thread starter Thread starter Filips Benoit
  • Start date Start date
F

Filips Benoit

Dear All,

Selecting 1 order in a listbox by code. Works OK, BUT
Opening a related form using Me.LstOrders.Column(0) as criteriavalue
sometimes triggers an error:
'There was a problem accessing a property or methode of the OLE object'

MsgBox Me.LstOrders.ItemsSelected.Count
MsgBox "[ORD_ID]= " & Me.LstOrders.Column(0)

When i insert these MsgBoxes before opening the form it shows:

1. If no error follows:
1
[ORD_ID]=1111
2. if error follow
1
[ORD_ID]=

In case 2 the selection is there but the value Me.LstOrders.Column(0) is not
accessible.

But why is it sometimes not accessible.

Reselecting the order manualy solves the problem.

THANKS,

FILIP
 
It's because the ListIndex of the ComboBox is set to -1, indicating that the
displayed value is Null or has no correspondance in the rowsource's values.

Use Column (0,0) instead of Column (0) when ListIndex is set to -1.

I'm not sure of your code but you can also use Me.LstOrders.Value

S. L.
 
Benoit said:
Dear All,

Selecting 1 order in a listbox by code. Works OK, BUT
Opening a related form using Me.LstOrders.Column(0) as criteriavalue
sometimes triggers an error:
'There was a problem accessing a property or methode of the OLE object'

MsgBox Me.LstOrders.ItemsSelected.Count
MsgBox "[ORD_ID]= " & Me.LstOrders.Column(0)

When i insert these MsgBoxes before opening the form it shows:

1. If no error follows:
1
[ORD_ID]=1111
2. if error follow
1
[ORD_ID]=

In case 2 the selection is there but the value Me.LstOrders.Column(0) is not
accessible.

But why is it sometimes not accessible.

Reselecting the order manualy solves the problem.

THANKS,

FILIP
 
Back
Top