Error 2115 - but not 'before update' ?

G

Guest

I am trying to move between records with the following code (in the AFTERT
Update event of a listbox):

Set rstMe = Me.RecordsetClone
rstMe.FindFirst "[Pupil ID] = " & Me!LstReqdPupil.ItemData(0)
If rstMe.NoMatch Then
MsgBox "Pupil ID not found when changing year group"
Else
Me.Bookmark = rstMe.Bookmark
End If

This raises the run-time error 2115 when it reaches the line 'Me.Bookmark =
rstMe.Bookmark'.

I am selecting from a listbox (LstReqdPupil) which is not linked to the
underlying data, this occurs even when no other controls change any data, and
when the are no 'before update' events used anywhere in the project.

Any suggestions where I should look for the problem?

Thanks.
 
A

Allen Browne

Access has to save the record before it can move to another one. Try
explicitly saving before the other code, e.g.:
If Me.Dirty Then Me.Dirty = False

My guess is that this will fail (saying the property can't be set), which
indicates that the current record cannot be saved. You must fix the problem
before you can move on.
 
G

Guest

Thanks for the reply, school hols are now over and it is back to work :-(

the immediate window reports me.dirty as already being false, which kind of
implies that no data has changed (which matches the reality as I see it).

The error message actually says ...
'The macro or function set to the BeforeUpdate or ValidationRule property
for this field is preventing Microsoft Office Access from saving the data in
the field'.

The error occurs when I am setting Me.Bookmark. Me.Name gives the name of
the form itself rather than a field. Is there a way to determine which
'field' the error message applies to?

Allen Browne said:
Access has to save the record before it can move to another one. Try
explicitly saving before the other code, e.g.:
If Me.Dirty Then Me.Dirty = False

My guess is that this will fail (saying the property can't be set), which
indicates that the current record cannot be saved. You must fix the problem
before you can move on.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Martin Folley said:
I am trying to move between records with the following code (in the AFTERT
Update event of a listbox):

Set rstMe = Me.RecordsetClone
rstMe.FindFirst "[Pupil ID] = " & Me!LstReqdPupil.ItemData(0)
If rstMe.NoMatch Then
MsgBox "Pupil ID not found when changing year group"
Else
Me.Bookmark = rstMe.Bookmark
End If

This raises the run-time error 2115 when it reaches the line 'Me.Bookmark
=
rstMe.Bookmark'.

I am selecting from a listbox (LstReqdPupil) which is not linked to the
underlying data, this occurs even when no other controls change any data,
and
when the are no 'before update' events used anywhere in the project.

Any suggestions where I should look for the problem?

Thanks.
 
G

Guest

I never managed to solve this one but compromised on how the form works.

It seems that I can use a click event on one unbound list box to change and
select different options in other unbound list boxes in a sort of cascade of
options, but that I cannot then move the underlying record based on these
changes. The final list box in the series must be clicked to move records, I
cannot do it via vba, even if no bound data has been changed at any point.

Martin Folley said:
Thanks for the reply, school hols are now over and it is back to work :-(

the immediate window reports me.dirty as already being false, which kind of
implies that no data has changed (which matches the reality as I see it).

The error message actually says ...
'The macro or function set to the BeforeUpdate or ValidationRule property
for this field is preventing Microsoft Office Access from saving the data in
the field'.

The error occurs when I am setting Me.Bookmark. Me.Name gives the name of
the form itself rather than a field. Is there a way to determine which
'field' the error message applies to?

Allen Browne said:
Access has to save the record before it can move to another one. Try
explicitly saving before the other code, e.g.:
If Me.Dirty Then Me.Dirty = False

My guess is that this will fail (saying the property can't be set), which
indicates that the current record cannot be saved. You must fix the problem
before you can move on.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Martin Folley said:
I am trying to move between records with the following code (in the AFTERT
Update event of a listbox):

Set rstMe = Me.RecordsetClone
rstMe.FindFirst "[Pupil ID] = " & Me!LstReqdPupil.ItemData(0)
If rstMe.NoMatch Then
MsgBox "Pupil ID not found when changing year group"
Else
Me.Bookmark = rstMe.Bookmark
End If

This raises the run-time error 2115 when it reaches the line 'Me.Bookmark
=
rstMe.Bookmark'.

I am selecting from a listbox (LstReqdPupil) which is not linked to the
underlying data, this occurs even when no other controls change any data,
and
when the are no 'before update' events used anywhere in the project.

Any suggestions where I should look for the problem?

Thanks.
 

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