469,639 Members | 1,558 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,639 developers. It's quick & easy.

Access 2000 Delete ADDs a New record? Help

Access 2000 Windows XP

Hi Everybody

I have got a weird one here.

I have a large form frmTransactions based on a single table
tblTransactions.

There are a lot of fields on the form but everything works OK. That is
until you want to delete a record on the EOF that not much data has
been entered. Where the user has started a new record without
completing it and just got the TransactionID entered.

So now I want them to be able to delete this record:
I have tried
DoCmd.RunCommand acCmdDeleteRecord
and I've tried
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord

But no joy.

Now here is the strange bit. As I delete this record it ADDs another
one with the autonumber, and I actually see one TransactionID disappear
and a higher one appear. Twighlight Zone stuff I think.

THis not happening with another form that I experimented with, or on
the table itself.

Any help would be most appreciated.

Bob

Dec 4 '05 #1
6 1931
bobdydd wrote:
Access 2000 Windows XP

Hi Everybody

I have got a weird one here.

I have a large form frmTransactions based on a single table
tblTransactions.

There are a lot of fields on the form but everything works OK. That is
until you want to delete a record on the EOF that not much data has
been entered. Where the user has started a new record without
completing it and just got the TransactionID entered.


If a new record has not yet been saved, then it cannot be deleted. You just
need to cancel the insertion.

If Me.NewRecord Then
'record never saved. just cancel it
Me.Undo
Else
'cancel any current changes
Me.Undo
DoCmd.RunCommand acCmdDeleteRecord
End If

I structured the above for clarity. Obviously you could just have a single Undo
before the If-Then block.

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Dec 4 '05 #2
Hi Rick

I altered it slighltly and it worked

DoCmd.RunCommand acCmdDeleteRecord
If Me.NewRecord Then
'record never saved. just cancel it
Me.Undo
Else
'cancel any current changes
Me.Undo
DoCmd.RunCommand acCmdDeleteRecord
End If

Thanks a lot

Dec 4 '05 #3
"bobdydd" <re**************@yahoo.co.uk> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com
Hi Rick

I altered it slighltly and it worked

DoCmd.RunCommand acCmdDeleteRecord
If Me.NewRecord Then
'record never saved. just cancel it
Me.Undo
Else
'cancel any current changes
Me.Undo
DoCmd.RunCommand acCmdDeleteRecord
End If

Thanks a lot


It looks to me like that's going to delete two records, most of the
time -- the current one, and the one after it. Are you sure it's doing
what you want?

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
Dec 5 '05 #4
Hi Dirk
Thanks for pointing that out. I have changed it to:

DoCmd.RunCommand acCmdDeleteRecord
If Me.NewRecord Then
'record never saved. just cancel it
Me.Undo
End If

Which ssems to do the trick

Dec 5 '05 #5
"bobdydd" <re**************@yahoo.co.uk> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com
Hi Dirk
Thanks for pointing that out. I have changed it to:

DoCmd.RunCommand acCmdDeleteRecord
If Me.NewRecord Then
'record never saved. just cancel it
Me.Undo
End If

Which ssems to do the trick


I still think you've got a problem there, and maybe you have error
messages turned off and aren't seeing it. What was wrong with the code
Rick Brandt originally posted? That code looks right to me.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
Dec 5 '05 #6

"Dirk Goldgar" <dg@NOdataSPAMgnostics.com> wrote in message
news:eJ**************@tk2msftngp13.phx.gbl...
"bobdydd" <re**************@yahoo.co.uk> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com
Hi Rick

I altered it slighltly and it worked

DoCmd.RunCommand acCmdDeleteRecord
If Me.NewRecord Then
'record never saved. just cancel it
Me.Undo
Else
'cancel any current changes
Me.Undo
DoCmd.RunCommand acCmdDeleteRecord
End If

Thanks a lot


It looks to me like that's going to delete two records, most of the
time -- the current one, and the one after it. Are you sure it's doing
what you want?

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Dec 6 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by John Phelan | last post: by
3 posts views Thread by Sebastian C. | last post: by
49 posts views Thread by Yannick Turgeon | last post: by
2 posts views Thread by bobdydd | last post: by
reply views Thread by laurent | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.