Problem with ListIndex = 0 in an AfterUpdate Event

A

Ashley

Can someone please explain to me why the below code produces
Run-Time Error '7777': You have used the ListIndex property
incorrectly.

The error occurs on the second last line of the code?
(Me.Combo2.ListIndex = 0)

Setting the listIndex to 0 for the first combo box works fine.
The two combo boxes are identicle, and the stored procedure is the
same for both combo boxes. This doesn't seem to make sense to me.

I have also tried using a value list as the source of the combo boxes
rather than a stored procedure, but still get the error message as
soon as I try to set the listIndex of the second combo box.

This is an MS Access 2002 project linking to SQL Server 2000.

----------------------------------------------------------------
Option Compare Database

Private Sub Form_Load()
Me.Combo1.RowSource = "EXEC spGetSourceSupplierList"

Me.Combo1.SetFocus
Me.Combo1.ListIndex = 0
End Sub

Public Sub Combo1_AfterUpdate()
Me.Combo2.RowSource = "EXEC spGetSourceSupplierList"

Me.Combo2.SetFocus
Me.Combo2.ListIndex = 0
End Sub
 
S

Stephen Lebans

The control has to have the focus in order to be able to set the
Listindex prop.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
G

Guest

But I am setting the focus to the control first......




Stephen Lebans said:
The control has to have the focus in order to be able to set the
Listindex prop.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
G

Guest

But I am setting the focus to the control first......



Stephen Lebans said:
The control has to have the focus in order to be able to set the
Listindex prop.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
G

Guest

Discovered that this code works with Access 2000 but not with Access 2002

Still don't know why it doesn't work in Access 2002 but will survive with
just using 2000





Ashley said:
But I am setting the focus to the control first......
 
R

Reggie

Ashley, Is it possible that the cobobox is bound to a field and that
that field properties are set to Required=Yes or Allow Zero Length = No.
Just a thought.

Reggie
 
S

Stephen Lebans

Just guessing but perhaps the rowsource for the second Combo has not
been completely loaded prior to you setting the ListIndex prop. You
should not have to but try placing a DoEvents prior to setting the
ListINdex prop.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


Ashley said:
But I am setting the focus to the control first......
 

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