Andy Cole - checking updates

  • Thread starter Thread starter pvp
  • Start date Start date
P

pvp

I am trying to achieve a system where there are no po-up
error messages - I just make visible error messages in
the form itself next to where the error originated among
its fields.
I use BeforeUpdate to check all fields are OK before
creating a new record. When I set Cancel to True, I get a
pop up error message 'you can't go to this record'. Is
there any way, when I find something wrong in a new
record's data, that I can quietly return to the form for
corrections to be made without this message coming up?

Thanks,
 
Hi pvp

The closest error message I know of that is similar the message you posted
is "You can't go to the specified record. You may be at the end of a
recordset" which has an error number of 2105. Getting this error suggests
that in the BeforeUpdate event (or the code that triggered that BeforeUpdate
event) you have some code that attempts to move to a particular record
which is being blocked by the Cancel parameter of the Before Update being
set. You could try trapping the error in the Form's OnError event to
determine what the error number is along the lines;

Private Sub Form_Error(DataErr As Integer, Response As Integer)

If DataErr = 2105 Then
Response = acDataErrContinue
Else
Me.lbError.Caption = "Error: " & DataErr & " (" & Error(DataErr) &
")"
Response = acDataErrContinue
End If

End Sub

This traps error 2105 and ignores it by setting the Response parameter to
acDataErrContinue which prevents Access from displaying the default message.
The Else part sets a label caption to the DataErr number and its
corresponding description so that you can get the DataErr number should it
not be 2105.

However, your BeforeUpdate code may include additional commands *after*
setting the Cancel parameter to True and it may be this is causing the
error. Can you post the BeforeUpdate code?

Andy
 
The form_error coding does not seem to work - I still get
the "you can't go..." message.

My BeforeUpdate has nothing in it to try to get to a
record but this brings up another thought... I use almost
any record-shifting button as well new record and exit to
actually update the d/b table record with the new record.
What do you recommend as the best way to 'commit' a form-
full of data to a new d/b table record?

Many thanks for your help to date.
 
Back
Top