Incorrect err returned to caller when cancel and show MsgBox in BeforeUpdate

S

Stephan

Under certain conditions, the calling
code "DoCmd.RunCommand acCmdSaveRecord" is returned an
err 3021 (No current record) when it should be receiving
an err 2401 (The RunCommand action was canceled).
This occurs when the data entry form has been opened
on a new record from another form and a message box is
displayed in Form_BeforeUpdate explaining why cancel was
set to true. This is a common data validation technique
used in many of our programs; so I've already spent hours
trying to find some newsgroup discussion about it but
haven't found anything.
I am porting from Access 9 to 11 (on WinXP SP1, with
Jet SP8 applied) and am uncomfortable with having to trap
the 3021 in a place where it has no business appearing.
 
T

TC

I take it that the data entry form (not the form which called the data entry
form) is executing the saverecord?

If so, what is the contenx (event etc.) from which it executes that call?

TC
 
M

[MVP] S.Clark

Since you're opeening to the newrecord, perhaps you can check for that prior
to trying to execute the save, which should suppress the error message.

If not me.newrecord and me.dirty then
DoCmd.RunCommand acCmdSaveRecord
end if


--
HTH,

Steve Clark, Access MVP
FMS, Inc.
Professional Solutions Group
http://www.FMSInc.com
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Is your Access database too slow?
Are you ready to upgrade to SQL Server?
Contact us for optimization and/or upsizing!
http://www.FMSInc.com/consulting
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 

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