2001 "you cancelled the previous operation"

M

Martin Folley

I cannot see the wood for the trees with this error.
The error occurs at Me.Bookmark = rstMe.Bookmark

I am trying to set the contents of a form's list box according to the time
of day when it is opened. I can set the contents and the value of the control
I then call the control's click function to trigger the code that would run
should the control be clicked. This calls the following sub.
I cannot see any 'cancelling'. There is no filter involved on the form.

Any suggestions as to where I should look?

Thanks.

Sub MoveToPupil(lngPupilID As Long)
Dim rstMe As Recordset
Dim bkmkMe As BookmarkEnum

Set rstMe = Me.RecordsetClone
rstMe.FindFirst "[Pupil ID] = " & lngPupilID
If rstMe.NoMatch Then
MsgBox "Pupil ID not found (ID:" & lngPupilID & ")"
Else
Me.Bookmark = rstMe.Bookmark
End If

End Sub
 
D

Douglas J. Steele

Are you certain that the field is, in fact, named Pupil ID (with the space)?
That misleading error message can occur when a name is mistyped.
 
M

Martin Folley

Yes the space is correct, as seems to be the code above.

If I comment out the relevant 'form open' code (so that the from opens using
default values), and click on the list control itself to run the 'click event
code' (part of which is above) then the code behaves normally. It only
appears to crash when the click event code is called as part of another sub
rather than as the result of a physical click.



Douglas J. Steele said:
Are you certain that the field is, in fact, named Pupil ID (with the space)?
That misleading error message can occur when a name is mistyped.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Martin Folley said:
I cannot see the wood for the trees with this error.
The error occurs at Me.Bookmark = rstMe.Bookmark

I am trying to set the contents of a form's list box according to the time
of day when it is opened. I can set the contents and the value of the
control
I then call the control's click function to trigger the code that would
run
should the control be clicked. This calls the following sub.
I cannot see any 'cancelling'. There is no filter involved on the form.

Any suggestions as to where I should look?

Thanks.

Sub MoveToPupil(lngPupilID As Long)
Dim rstMe As Recordset
Dim bkmkMe As BookmarkEnum

Set rstMe = Me.RecordsetClone
rstMe.FindFirst "[Pupil ID] = " & lngPupilID
If rstMe.NoMatch Then
MsgBox "Pupil ID not found (ID:" & lngPupilID & ")"
Else
Me.Bookmark = rstMe.Bookmark
End If

End Sub
 
M

Magius96

Since it works when you actually click on the control, try moving the code
into it's own subroutine then call that subroutine where you need it. You
may be getting the error as a result of calling the OnClick event when there
was no click event.

Of course, my explanation of the error may be wrong, but it's probably the
best way to handle this.

Martin Folley said:
Yes the space is correct, as seems to be the code above.

If I comment out the relevant 'form open' code (so that the from opens using
default values), and click on the list control itself to run the 'click event
code' (part of which is above) then the code behaves normally. It only
appears to crash when the click event code is called as part of another sub
rather than as the result of a physical click.



Douglas J. Steele said:
Are you certain that the field is, in fact, named Pupil ID (with the space)?
That misleading error message can occur when a name is mistyped.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Martin Folley said:
I cannot see the wood for the trees with this error.
The error occurs at Me.Bookmark = rstMe.Bookmark

I am trying to set the contents of a form's list box according to the time
of day when it is opened. I can set the contents and the value of the
control
I then call the control's click function to trigger the code that would
run
should the control be clicked. This calls the following sub.
I cannot see any 'cancelling'. There is no filter involved on the form.

Any suggestions as to where I should look?

Thanks.

Sub MoveToPupil(lngPupilID As Long)
Dim rstMe As Recordset
Dim bkmkMe As BookmarkEnum

Set rstMe = Me.RecordsetClone
rstMe.FindFirst "[Pupil ID] = " & lngPupilID
If rstMe.NoMatch Then
MsgBox "Pupil ID not found (ID:" & lngPupilID & ")"
Else
Me.Bookmark = rstMe.Bookmark
End If

End Sub
 
M

Martin Folley

Thanks.
Should have thought of it earlier. Taking out the sub routines and copying
the code into one long sub that appears to do the same has made a difference
(no errors ... yet)


Magius96 said:
Since it works when you actually click on the control, try moving the code
into it's own subroutine then call that subroutine where you need it. You
may be getting the error as a result of calling the OnClick event when there
was no click event.

Of course, my explanation of the error may be wrong, but it's probably the
best way to handle this.

Martin Folley said:
Yes the space is correct, as seems to be the code above.

If I comment out the relevant 'form open' code (so that the from opens using
default values), and click on the list control itself to run the 'click event
code' (part of which is above) then the code behaves normally. It only
appears to crash when the click event code is called as part of another sub
rather than as the result of a physical click.



Douglas J. Steele said:
Are you certain that the field is, in fact, named Pupil ID (with the space)?
That misleading error message can occur when a name is mistyped.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I cannot see the wood for the trees with this error.
The error occurs at Me.Bookmark = rstMe.Bookmark

I am trying to set the contents of a form's list box according to the time
of day when it is opened. I can set the contents and the value of the
control
I then call the control's click function to trigger the code that would
run
should the control be clicked. This calls the following sub.
I cannot see any 'cancelling'. There is no filter involved on the form.

Any suggestions as to where I should look?

Thanks.

Sub MoveToPupil(lngPupilID As Long)
Dim rstMe As Recordset
Dim bkmkMe As BookmarkEnum

Set rstMe = Me.RecordsetClone
rstMe.FindFirst "[Pupil ID] = " & lngPupilID
If rstMe.NoMatch Then
MsgBox "Pupil ID not found (ID:" & lngPupilID & ")"
Else
Me.Bookmark = rstMe.Bookmark
End If

End Sub
 
M

Martin Folley

Arrrgh! it is back

It was working.
Tools repair and compact.
Not working ... operation being cancelled.

Use a break point to stop the code and walk through it ... working.

This implies that it is not a code issue, but possibly a timing issue.

Is there an internal (or hidden) time out used by access to determine
whether a report has stalled?
The report is not that big but it does access 20-30 external jpg files, and
contains about 150 controls.

Martin Folley said:
Thanks.
Should have thought of it earlier. Taking out the sub routines and copying
the code into one long sub that appears to do the same has made a difference
(no errors ... yet)


Magius96 said:
Since it works when you actually click on the control, try moving the code
into it's own subroutine then call that subroutine where you need it. You
may be getting the error as a result of calling the OnClick event when there
was no click event.

Of course, my explanation of the error may be wrong, but it's probably the
best way to handle this.

Martin Folley said:
Yes the space is correct, as seems to be the code above.

If I comment out the relevant 'form open' code (so that the from opens using
default values), and click on the list control itself to run the 'click event
code' (part of which is above) then the code behaves normally. It only
appears to crash when the click event code is called as part of another sub
rather than as the result of a physical click.



:

Are you certain that the field is, in fact, named Pupil ID (with the space)?
That misleading error message can occur when a name is mistyped.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I cannot see the wood for the trees with this error.
The error occurs at Me.Bookmark = rstMe.Bookmark

I am trying to set the contents of a form's list box according to the time
of day when it is opened. I can set the contents and the value of the
control
I then call the control's click function to trigger the code that would
run
should the control be clicked. This calls the following sub.
I cannot see any 'cancelling'. There is no filter involved on the form.

Any suggestions as to where I should look?

Thanks.

Sub MoveToPupil(lngPupilID As Long)
Dim rstMe As Recordset
Dim bkmkMe As BookmarkEnum

Set rstMe = Me.RecordsetClone
rstMe.FindFirst "[Pupil ID] = " & lngPupilID
If rstMe.NoMatch Then
MsgBox "Pupil ID not found (ID:" & lngPupilID & ")"
Else
Me.Bookmark = rstMe.Bookmark
End If

End Sub
 

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