error 7777

M

martin stirrup

I've got a problem with a bit of Access VB code that worked in our school
reporting system in XP version of Office 2003 for years but now dies in vista
version of 2007...

I'm getting :Runtime error 7777
you used ListIndex property incorrectly

when it tries to move on to the next record in the subroutine


Private Sub cmdOK_Click()

Dim intNextRecord As Integer

intNextRecord = cboStudent.ListIndex + 1

If intNextRecord = cboStudent.ListCount Then

intNextRecord = 0

End If

cboStudent.SetFocus

cboStudent.ListIndex = intNextRecord 'this line gives the grief'

End Sub

I've tried looking this up but there is some confusion as to whether
ListIndex is read/write or read only in 2007. How else can I easily make this
move on to the next record?

PS I'm no programmer, so make it simple and easily intelligable please!
 
M

martin stirrup

thanks for the prompt reply - I'll give it a go ... we have had network
changes but i still suspect a 2003-2007 issue as I have two pc side by side
trying to run the same file. It works perfect on the one with XL/Office 2003
but gives error 7777 on the Vista/2007 one...
 
B

BeWyched

Your coding is fine - I've tried it on my Vista/2007 PC and it works.

2 possible explanations:
1. Follow Linq Adams guidance.
2. The .SetFocus line is essential. This will fail if the List Box's Enabled
property is set to False, or it's Locked property is set to True.

Good luck.

BW
 
M

martin stirrup

just to round this off...

there seems to be total confusion as to whether ListIndex is writable or not
in all the microsoft helpfiles... In the end I noticed that if I clicked
'end' on the error message, the programme moved on to the end rtecord quite
happily... so I got a bit of code to suppress the error message (from my son
in the end!) and it all now seems to work fine.... ho hum

on error resume next
<line of code that breaks >
on error goto 0


thanks for the support though - much appreciated
 

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