Check if record is blank before attempting to delete the record

L

laavista

I have a module that will be called by all my forms if the user selects
"delete record" button. The module asks if the user is sure they wish to
delete the record, then deletes it if they indicate yes. This works fine
unless the record is blank (new).

Is there a function or method to check if the record is blank?

(I'm using Access 2007)

Thanks for your help!
 
D

daniel.ran.xu

I have a module that will be called by all my forms if the user selects
"delete record" button.  The module asks if the user is sure they wish to
delete the record, then deletes it if they indicate yes.  This works fine
unless the record is blank (new).  

Is there a function or method to check if the record is blank?  

(I'm using Access 2007)

Thanks for your help!

Why user can delete it if there is no record? User should not see it
at all, how they delete it?
 
J

John W. Vinson

Why user can delete it if there is no record? User should not see it
at all, how they delete it?

Well, they'll see the blank "new record", which isn't actually stored in the
table until it's been dirtied and then saved. So the button event code can
just check for Me.NewRecord; if that property is true the code can simply exit
and do nothing, since there's nothing that needs to be done.
 
D

David W. Fenton

Well, they'll see the blank "new record", which isn't actually
stored in the table until it's been dirtied and then saved. So the
button event code can just check for Me.NewRecord; if that
property is true the code can simply exit and do nothing, since
there's nothing that needs to be done.

Well, I'd say a DELETE command button shouldn't be enabled until the
record has been saved, so as long as Me.NewRecord is true, I
wouldn't enable the DELETE button at all.
 

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