run-time error 2115 on refresh/requery

run-time error 2115 on refresh/requery

Post by John Malon » Mon, 15 Jul 2002 22:26:59



2 issues actually

I have a subform that uses Form_BeforeUpdate to confirm user changes.

Private Sub Form_BeforeUpdate(Cancel As Integer)
    If Me.Dirty = True Then      
        If MsgBox("Data on this page has been edited." & vbCrLf & _
        vbCrLf & "Save changes?", vbYesNo, "Data Protection") = vbNo
Then
            Me.Undo
        End If
    End If
End Sub

1st issue:  Form_AfterUpdate does not fire.  ADP's seem to have issues
with events not firing - I've seen this in other places - esp. when
using a tab control.

So fine, I'll call Form_AfterUpdate explicitly.  I use this event to
conditionally refresh/requery the parent form.

2nd issue (problem!):
Any attempt at refresh/requery results in run-time error 2115 - "The
macro or function set to the BeforeUpdate or ValidationRule property
for this field is
preventing <application> from saving the data in the field"

I've tried every method of refreshing or requering the recvordset that
I know.  No luck.  The new values that i want to appear onscreen are
already in the tables, I just need the form to update.

John

 
 
 

run-time error 2115 on refresh/requery

Post by John Malon » Wed, 17 Jul 2002 11:19:11


FYI,

I was always getting a write conflict error (caused by an update
trigger) which I was trapping in the form_Error event and basically
ignoring ie:

Form_Error(DataErr As Integer, Response As Integer)

    If DataErr = 2169 Or 7787 Then
        Response = acDataErrContinue
...

I think I got this code from Andy Baron and it seemed fine since it
was apparently saving the new value.

However, it seems there were consequences in that "Response =
acDataErrContinue" wasn't clearing the error (I'm guessing) and that
was preventing Form_AfterUpdate from firing (FYI Form_BeforeUpdate was
firing normally).

When I could call Form_AfterUpdate explicitly as a workaround, Access
(or SQL Server or a provider) would block my attempt to
refresh/requery since this forces a save and the original write
conflict error was "still in effect".  This is the best deduction I
can come up with.

Eliminating the Update trigger eliminated all problems.  I still don't
know why it was a problem.  I can't find anything wrong in the
Trigger's syntax and I'm frustrated at the lack of debugging tools.  I
ended up moving the code to a sproc and creating a new update trigger
that simply executes the sproc. All works fine now.

 
 
 

run-time error 2115 on refresh/requery

Post by RJE » Thu, 18 Jul 2002 03:03:58


First, I'd lose the confirmations -- very annoying.  If you have problems
with users who "shouldn't" be changing data screwing things up - create
"groups" and put them in one that is datareader only.

Second, instead of Me.Undo, try using Cancel = True.

Third, "AfterUpdate" is not running because your canceling the BeforeUpdate,
and the Save that happens between the two events (BeforeUpdate - validation,
cancelable if validation fails, then the backend "save", then AfterUpdate,
to do things like refresh calced controls, etc).  You have two problems
here.  First, you aren't really "canceling" the validation event (but it is
stopping) because you're doing an undo instead (the effect is the same, but
it "flows" differently downstream - in effect, you're "pushing the esc
key").  The errors downstream from that are because you've messed up the
order.  Like by calling AfterUpdate when there hasn't been an update, or
when the form is "dirty" because you cancelled the save.  The 2115 error is
what you get if you try to requery or call AfterUpdate from BeforeUpdate.
The form is dirty until AFTER the BeforeUpdate finishes.  Requery with the
form dirty calls an implicit Save, which triggers BeforeUpdate.  So if you
call AfterUpdate (or Requery) from the BeforeUpdate, you call BeforeUpdate
AGAIN (form's still dirty).  And if you cancel EITHER call, then the OTHER
one gets the 2115 RTE.

Jay


Quote:> 2 issues actually

> I have a subform that uses Form_BeforeUpdate to confirm user changes.

> Private Sub Form_BeforeUpdate(Cancel As Integer)
>     If Me.Dirty = True Then
>         If MsgBox("Data on this page has been edited." & vbCrLf & _
>         vbCrLf & "Save changes?", vbYesNo, "Data Protection") = vbNo
> Then
>             Me.Undo
>         End If
>     End If
> End Sub

> 1st issue:  Form_AfterUpdate does not fire.  ADP's seem to have issues
> with events not firing - I've seen this in other places - esp. when
> using a tab control.

> So fine, I'll call Form_AfterUpdate explicitly.  I use this event to
> conditionally refresh/requery the parent form.

> 2nd issue (problem!):
> Any attempt at refresh/requery results in run-time error 2115 - "The
> macro or function set to the BeforeUpdate or ValidationRule property
> for this field is
> preventing <application> from saving the data in the field"

> I've tried every method of refreshing or requering the recvordset that
> I know.  No luck.  The new values that i want to appear onscreen are
> already in the tables, I just need the form to update.

> John

 
 
 

1. 24 hour time switches to incorrect am/pm time

Occassionally our SQL 7.0 sp1 on NT sp5 will change the time stamp on a
record from say 5-8-00 01:00:00 to 5-8-00 1:00 pm. It has also gone from
13:00 back to 1:00  am. This occurs at no particular date or time. A partial
solution seems to be to leave the SQL server logged in all the times. We
have already set all computers on our network to 24 hour clock. We also
hacked the registry and set all Default settings to 24 hour.
HELP!!

Rick Griffy, MCP

2. "connection to server is lost" error

3. Changing Query Plans - Slow one time/Fast Another Time

4. Date Problem

5. Can't read time from Access 2000 date/time field

6. PARADOX ISN'T FULLY YEAR 2000 COMPATIBLE!!!

7. HELP : odbc date time settings switch all the time

8. PreparedStatement.setTimestamp(int, Timestamp) with Access 97 not working

9. Payroll question- Handling sick time, vacation, compensatory time, personal

10. First Time on Newsgroups a second time around!

11. How to keep a reasonable response time when a time-consuming SQL statement running

12. System Time and SQL Server time

13. SQL development time vs Jet development time