Listbox-problem

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
 
S

Sylvain Lafontaine

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top