Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / January 2008

Tip: Looking for answers? Try searching our database.

Prohibiting record deletion

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John - 14 Jan 2008 01:28 GMT
Hi

When a user presses Delete key to delete a record, I need to check the value
of one of the record fields on the form and depending on the value I need to
allow or not the deletion of record to go ahead. What form event should I
use for this purpose?

Thanks

Regards
Dirk Goldgar - 14 Jan 2008 02:33 GMT
> Hi
>
> When a user presses Delete key to delete a record, I need to check the
> value of one of the record fields on the form and depending on the value I
> need to allow or not the deletion of record to go ahead. What form event
> should I use for this purpose?

I think it's the form's Delete event that you want for this.  You can cancel
it to prevent a record from being deleted, and I think in this event the
current record whose fields you can interrogate is the record that is about
to be deleted.  (I'm not sure about the BeforeDelConfirm event, and that
won't not fire if the user has delete confirmations turned off.)  Also, if
multiple records are selected for deletion, the Delete event fires for each
of them.

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Dirk Goldgar - 14 Jan 2008 03:00 GMT
> I think it's the form's Delete event that you want for this.  You can
> cancel it to prevent a record from being deleted, and I think in this
> event the current record whose fields you can interrogate is the record
> that is about to be deleted.  (I'm not sure about the BeforeDelConfirm
> event, and that won't not fire if the user has delete confirmations turned
> off.)

Err, I meant "won't fire", not "won't not fire".  And I just checked, and in
the Before DelConfirm event, the values of the form controls are for the
residual record *after* the record(s) have been deleted.  So Delete looks
like a better event for your purpose.

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Tom van Stiphout - 14 Jan 2008 02:48 GMT
You need a cancellable event. BeforeDelConfirm comes to mind.
-Tom.

>Hi
>
[quoted text clipped - 6 lines]
>
>Regards
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.