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!
 
L

Linq Adams via AccessMonster.com

When apps run fine on one machine and not on another or run fine in one
version and not when run under a newer version, the first thing you have to
think about are missing references.

Here are Doug Steele's instructions on how to troubleshoot the problem:

*** Quote ***

Any time functions that previously worked suddenly don't, the first thing to
suspect is a references problem.

This can be caused by differences in either the location or file version of
certain files between the machine where the application was developed, and
where it's being run (or the file missing completely from the target machine).
Such differences are common when new software is installed.

On the machine(s) where it's not working, open any code module (or open the
Debug Window, using Ctrl-G, provided you haven't selected the "keep debug
window on top" option). Select Tools | References from the menu bar. Examine
all of the selected references.

If any of the selected references have "MISSING:" in front of them, unselect
them, and back out of the dialog. If you really need the reference(s) you
just unselected (you can tell by doing a Compile All Modules), go back in and
reselect them.

If none have "MISSING:", select an additional reference at random, back out
of the dialog, then go back in and unselect the reference you just added. If
that doesn't solve the problem, try to unselect as many of the selected
references as you can (Access may not let you unselect them all), back out of
the dialog, then go back in and reselect the references you just unselected.
(NOTE: write down what the references are before you delete them, because
they'll be in a different order when you go back in)

For far more than you could ever want to know about this problem, check out

http://www.accessmvp.com/djsteele/AccessReferenceErrors.html

Just so you know: the problem will occur even if the library that contains
the specific function that's failing doesn't have a problem.

**** End Quote ****
 
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