Re: Lost Record after data entry

From: Allen Browne (AllenBrowne_at_SeeSig.Invalid)
Date: 07/26/04


Date: Mon, 26 Jul 2004 16:29:24 +0800

That line has a different purpose.

Me.Refresh will save the record if there is no problem, but generates no
error message if there is, so is useless.

RunCommand acCmdSaveRecord works on the active form, which may not be the
one you intend.

The wizard-generated DoCmd.DoMenuItem ... has the same problem, as well as
it arcane menu dependency.

Setting Dirty to False is the only way I know of to guarantee the save
worked on the intended form.

-- 
Allen Browne - Microsoft MVP.  Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Mark S" <na@na.com> wrote in message
news:lvc9g0dbv52251d0ghtcr87vss304h12av@4ax.com...
> I came across the following line of code:
>
>     DBEngine.Idle dbRefreshCache
>
> Will that work also?
>
> On Fri, 23 Jul 2004 16:33:59 +0800, "Allen Browne"
> <AllenBrowne@SeeSig.Invalid> wrote:
>
> >The problem is with the Close action/method.
> >
> >If there is any reason why the record cannot be saved (e.g. required
field
> >missing, validation rule not met, duplicate index error, ...) Access just
> >discards your record without notifying you.
> >
> >Surely that is a serious data loss bug! Access is supposed to save by
> >default. This bug has been present since at least version 2 of Access, so
> >don't hold your breath waiting for Microsoft to fix it, even though there
is
> >a very long line of people who have been hurt by this bug.
> >
> >Once you know the bug is there, it is easy enough to work around it.
*Never*
> >issue a close without first explicitly saving the record, e.g.:
> >    If Me.Dirty Then
> >        Me.Dirty = False
> >    End If
> >    DoCmd.Close acForm, Me.Name
> >
> >More information in article:
> >    Losing data when you close a form
> >at:
> >    http://allenbrowne.com/bug-01.html