Setting Listindex within AfterUpdate event

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
-----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
 
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
 
Back
Top