Adding records without navigation buttons

C

choriflai

I'm developing a search form to filter specific records. The user can either
edit a record or add a new one using an Edit or Add command buttons
respectively. I'm able to display a blank record on another form with an OK
and Cancel command buttons (no navigation buttons). What I would like to do
is that if the user clicks on the Cancel button, the record gets deleted. Can
it be done?
 
E

ErezM via AccessMonster.com

hi
if i got it right, you want your "cancel" button to delete a new record
that's being added? if so, then at the click event of the cancel button,
write "Docmd.Undo" and the newly added record will be discarded.
the same works fine for editing an existing record, but then of course, Undo
reverts to the saved record and discards changes, but doesnt delete the
record

good luck
Erez
 
C

choriflai via AccessMonster.com

Erez,

I tried your suggestion, but it still creates a record in spite of the Docmd.
Undo command. Any other suggestions out there?

Thanks,

choriflai
 
C

choriflai via AccessMonster.com

Actually, I'm using Me.Undo since you cannot do DoCmd.Undo
Erez,

I tried your suggestion, but it still creates a record in spite of the Docmd.
Undo command. Any other suggestions out there?

Thanks,

choriflai
hi
if i got it right, you want your "cancel" button to delete a new record
[quoted text clipped - 13 lines]
 
E

ErezM via AccessMonster.com

hi again
you need to check: if you are on a new record, undo will do the job and you
are doing something else wrong, if you are not on a new record then you need
to delete it, so on the cancel button's click event:

If Me.NewRecord Then
Me.Undo
Else
DoCmd.RunCommand acCmdDeleteRecord
End If

and probably:

DoCmd.Close

to close the form

Erez
Actually, I'm using Me.Undo since you cannot do DoCmd.Undo
[quoted text clipped - 10 lines]
 

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