PC Review


Reply
Thread Tools Rate Thread

How to delete just one record?

 
 
José António Silva
Guest
Posts: n/a
 
      20th Jun 2009
Is there any way to prevent users from selecting more than one record in a
datasheet form view and try to delete them all at once?

I need to make some stuff when a record is deleted, and I code it in the ‘on
delete’ event. The problem arises when I need to compute a maximum date over
the same table where the user is deleting, perhaps, some records. Since the
form creates itself a transaction to delete all the selected records, I will
get an error because my code waits indefinitely by the ODBC answer of maximum
date.

If the user deletes just one record, this won’t happen. My code stops when
trying to compute maximum date for a second record select for deletion at
once.

Any help will be welcome,
Thanks,
JS

 
Reply With Quote
 
 
 
 
David H
Guest
Posts: n/a
 
      21st Jun 2009
Not to my knowledge. Instead of giving them access to the datasheet view, go
with a continuous form that includes the fields that they need.

"José António Silva" wrote:

> Is there any way to prevent users from selecting more than one record in a
> datasheet form view and try to delete them all at once?
>
> I need to make some stuff when a record is deleted, and I code it in the ‘on
> delete’ event. The problem arises when I need to compute a maximum date over
> the same table where the user is deleting, perhaps, some records. Since the
> form creates itself a transaction to delete all the selected records, I will
> get an error because my code waits indefinitely by the ODBC answer of maximum
> date.
>
> If the user deletes just one record, this won’t happen. My code stops when
> trying to compute maximum date for a second record select for deletion at
> once.
>
> Any help will be welcome,
> Thanks,
> JS
>

 
Reply With Quote
 
Dirk Goldgar
Guest
Posts: n/a
 
      22nd Jun 2009

"José António Silva" <(E-Mail Removed)> wrote in
message news:149BCE74-5BF8-4449-B4A6-(E-Mail Removed)...
> Is there any way to prevent users from selecting more than one record in a
> datasheet form view and try to delete them all at once?
>
> I need to make some stuff when a record is deleted, and I code it in the
> ‘on
> delete’ event. The problem arises when I need to compute a maximum date
> over
> the same table where the user is deleting, perhaps, some records. Since
> the
> form creates itself a transaction to delete all the selected records, I
> will
> get an error because my code waits indefinitely by the ODBC answer of
> maximum
> date.
>
> If the user deletes just one record, this won’t happen. My code stops when
> trying to compute maximum date for a second record select for deletion at
> once.



In the form's Delete event, you can check the form's SelHeight property to
see if more than one record is selected, and cancel the delete in that case.
For example:

Private Sub Form_Delete(Cancel As Integer)

If Me.SelHeight > 1 Then
Cancel = True
Else
' ... do the original work ...
End If

End Sub

Unfortunately, you can't easily display a message to the user explaining why
the delete was cancelled, because the message will be displayed for every
selected record (as the Delete event fires for each record).

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

(please reply to the newsgroup)

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Prevent Subform from saving record or delete record when moving tomain form RussCRM Microsoft Access Form Coding 0 3rd Apr 2008 07:26 PM
Re: Add / Delete record from table - How to reposition selected record in datagridview??? Cor Ligthert[MVP] Microsoft VB .NET 0 31st Mar 2008 05:26 AM
How to delete a SQL Server record (descending from another record of the same table) with a C# application polocar Microsoft C# .NET 6 23rd Jul 2006 03:20 AM
Upon delete record, conditional delete record from another table =?Utf-8?B?UmljaDEyMzQ=?= Microsoft Access 6 14th Oct 2005 02:48 PM
Delete Button shows previous record before current record is delet =?Utf-8?B?UmljaDEyMzQ=?= Microsoft Access Forms 8 10th Oct 2005 01:15 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:40 PM.