K
kaioptera
I have a form in an ADP connected to a SQL Server 2005 backend, with a
record source that is a view that includes two joins but is still
updateable.
The form has a list box control in the header section that is supposed
to allow the user to select a record to show in the detail section, set
up by the list box wizard, which created the following code to
implement this functionality:
Private Sub List52_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.recordSet.Clone
rs.Find "[cp_trust] = '" & Me![List52] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
For all records except one, I can change the record and then select a
different record in the list box, and have the record I changed be
updated as I move away to a different record.
BUT if the *first record* in the list box is selected, and I change a
value in that record, when I move to a different record, I get
"Run-time error 2001: You canceled the previous operation.", on the
line that assigns Me.Bookmark. I know from SQL Profiler that the record
has already been updated before this error pops up. If I click "End" to
get rid of the error window and select a different record, the error
pops up again, unless (and this is weird) there is another record in
the list box with the same value of cp_trust as the first record, in
which case the error doesn't come up, but the current record doesn't
actually change, either. If I change the rs.Find criterion from
cp_trust to a unique ID, we still get the error (2001), but the
behavior of having a record we can move to without throwing an error
after having changed the first record disappears.
If after getting one of these errors I move back to the first record
and press Escape, the little pencil icon that indicates a record has
changed goes away, the change is NOT rolled back in the database or on
the form, and I can now switch records without any errors.
If I add a line to call Me.Recordset.Update at the beginning of the
AfterUpdate sub, the new line causes the update *only in the case of
the first record having changed*, the line has no effect for changes to
other records, in which case the update goes through when the line that
assigns Me.Bookmark is executed. (I know this from stepping through the
code while watching SQL Profiler)
As a final control, if I make a form that doesn't have the list box
control, I can modify the first record and move to a different record
without causing the error.
I've gathered all this behavioral information in the hopes of finding a
workaround, to no avail.
So I ask you: what ON EARTH is going on here?
record source that is a view that includes two joins but is still
updateable.
The form has a list box control in the header section that is supposed
to allow the user to select a record to show in the detail section, set
up by the list box wizard, which created the following code to
implement this functionality:
Private Sub List52_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.recordSet.Clone
rs.Find "[cp_trust] = '" & Me![List52] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
For all records except one, I can change the record and then select a
different record in the list box, and have the record I changed be
updated as I move away to a different record.
BUT if the *first record* in the list box is selected, and I change a
value in that record, when I move to a different record, I get
"Run-time error 2001: You canceled the previous operation.", on the
line that assigns Me.Bookmark. I know from SQL Profiler that the record
has already been updated before this error pops up. If I click "End" to
get rid of the error window and select a different record, the error
pops up again, unless (and this is weird) there is another record in
the list box with the same value of cp_trust as the first record, in
which case the error doesn't come up, but the current record doesn't
actually change, either. If I change the rs.Find criterion from
cp_trust to a unique ID, we still get the error (2001), but the
behavior of having a record we can move to without throwing an error
after having changed the first record disappears.
If after getting one of these errors I move back to the first record
and press Escape, the little pencil icon that indicates a record has
changed goes away, the change is NOT rolled back in the database or on
the form, and I can now switch records without any errors.
If I add a line to call Me.Recordset.Update at the beginning of the
AfterUpdate sub, the new line causes the update *only in the case of
the first record having changed*, the line has no effect for changes to
other records, in which case the update goes through when the line that
assigns Me.Bookmark is executed. (I know this from stepping through the
code while watching SQL Profiler)
As a final control, if I make a form that doesn't have the list box
control, I can modify the first record and move to a different record
without causing the error.
I've gathered all this behavioral information in the hopes of finding a
workaround, to no avail.
So I ask you: what ON EARTH is going on here?