Setting Listindex within AfterUpdate event

G

Guest

Can someone please explain why the following code causes a "Run-time error
'7777': You have used the listindex property incorrectly" error on the
second last line of the code.

The two combo boxes are identicle and I am using the same stored procedure
as the rowsource. Setting the listIndex for the first combo box works fine
but not the second combo box. It doesn't make sense to me.


----------------------------------------------------------------------------------------
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 Su
 
J

Jonathan Parminter

-----Original Message-----
Can someone please explain why the following code causes a "Run-time error
'7777': You have used the listindex property incorrectly" error on the
second last line of the code.

The two combo boxes are identicle and I am using the same stored procedure
as the rowsource. Setting the listIndex for the first combo box works fine
but not the second combo box. It doesn't make sense to me.
------------------------------
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
---------------------------------------------------------- ------------------------------

Thanks
Ashley

.

Hi Ashley,
what are you actually trying to have as an outcome?

If you want to have the first item selected, then try...
with Me.Combo2
.RowSource = "EXEC spGetSourceSupplierList"
.SetFocus
.value=.itemdata(0)
end with

Luck
Jonathan
 
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
 

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