A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

delete



 
 
Thread Tools Display Modes
  #1  
Old October 10th, 2005, 12:52 PM
Rich1234
external usenet poster
 
Posts: n/a
Default delete

hi
I have a continuous subform set to AllowDeletions = true. I have a delete
button on each record in the subform. On the subform's before delete confirm
event, I have changed the default message and have set up a custom message
instead. In this message I am including the name fields from the record
which will be deleted as additional confirmation for the user. Even though
the correct record is deleted, this confirmation box is showing fields (First
Names and Surname) from the next record in the form! Why is this? And when I
click on the delete button for the very last record in the subform, it says
the names from the previous record in the form in the delete confirmation
message box. Very strange.

Here is the code I'm using for the subform's before delete confirm event:

Private Sub Form_BeforeDelConfirm(Cancel As Integer, Response As Integer)
' Suppress default Delete Confirm dialog box.
Response = acDataErrContinue
' Display custom dialog box.
If MsgBox("Are you sure you want to remove the driver " & [First Names]
& " " & Surname & " from this vehicle?" & vbNewLine & _
, vbOKCancel) = vbCancel Then
Cancel = True
End If
End Sub

I know that by default when you delete a record, the form shows the next
record in the table or query when the before delete confirmation message box
is displayed (even though the "current" record hasn't been deleted yet.)
Please see the post at

http://www.microsoft.com/office/comm...xp=&sloc=en-us

(or find this post, "Delete Button Shows Previous Record Before the Current
Record is Deleted" in Access Forms in this forum.)

I imagine this is this something to do with it. Do you know a way around
this? Do I need to put the Application.Echo False into the Before Delete
Confirm code too?

Please help if you can.
TIA
Rich

  #2  
Old October 10th, 2005, 01:35 PM
Van T. Dinh
external usenet poster
 
Posts: n/a
Default

I think BeforeDelConfirm Event actually happens AFTER the Record(s) is
deleted from the Form buffer (but the deletion has not been propagated to
the actual Table(s). Hence, the Current Record is the one *after* the
Record which has just been deleted from the buffer.

Check Access VB Help for further info ...

For confirmation Msg, stick the MsgBox in your CommandButton_Click Event and
depending on the Response, proceed or skip the deletion code as required.

--
HTH
Van T. Dinh
MVP (Access)



"Rich1234" wrote in message
...
hi
I have a continuous subform set to AllowDeletions = true. I have a delete
button on each record in the subform. On the subform's before delete
confirm
event, I have changed the default message and have set up a custom message
instead. In this message I am including the name fields from the record
which will be deleted as additional confirmation for the user. Even
though
the correct record is deleted, this confirmation box is showing fields
(First
Names and Surname) from the next record in the form! Why is this? And
when I
click on the delete button for the very last record in the subform, it
says
the names from the previous record in the form in the delete confirmation
message box. Very strange.

Here is the code I'm using for the subform's before delete confirm event:

Private Sub Form_BeforeDelConfirm(Cancel As Integer, Response As Integer)
' Suppress default Delete Confirm dialog box.
Response = acDataErrContinue
' Display custom dialog box.
If MsgBox("Are you sure you want to remove the driver " & [First Names]
& " " & Surname & " from this vehicle?" & vbNewLine & _
, vbOKCancel) = vbCancel Then
Cancel = True
End If
End Sub

I know that by default when you delete a record, the form shows the next
record in the table or query when the before delete confirmation message
box
is displayed (even though the "current" record hasn't been deleted yet.)
Please see the post at

http://www.microsoft.com/office/comm...xp=&sloc=en-us

(or find this post, "Delete Button Shows Previous Record Before the
Current
Record is Deleted" in Access Forms in this forum.)

I imagine this is this something to do with it. Do you know a way around
this? Do I need to put the Application.Echo False into the Before Delete
Confirm code too?

Please help if you can.
TIA
Rich



  #3  
Old October 10th, 2005, 01:39 PM
Brendan Reynolds
external usenet poster
 
Posts: n/a
Default

As Van indicates elsewhere in this thread, you no longer have access (no pun
intended) to the about-to-be-deleted value in the BeforeDelConfirm event
procedure. The last event in which you still have access to this value is
the Delete event procedure. What you could do is use the Delete event
procedure to store the value in a module-level variable, then refer to that
variable in the BeforeDelConfirm event procedure, like so ...

Option Compare Database
Option Explicit

Private mstrValue As String

Private Sub Form_BeforeDelConfirm(Cancel As Integer, Response As Integer)

Response = acDataErrContinue
Cancel = MsgBox("Are you sure you want to delete the record with value
'" _
& mstrValue & "'?", vbYesNo) = vbNo

End Sub

Private Sub Form_Delete(Cancel As Integer)

mstrValue = TestText & vbNullString

End Sub

--
Brendan Reynolds


"Rich1234" wrote in message
...
hi
I have a continuous subform set to AllowDeletions = true. I have a delete
button on each record in the subform. On the subform's before delete
confirm
event, I have changed the default message and have set up a custom message
instead. In this message I am including the name fields from the record
which will be deleted as additional confirmation for the user. Even
though
the correct record is deleted, this confirmation box is showing fields
(First
Names and Surname) from the next record in the form! Why is this? And
when I
click on the delete button for the very last record in the subform, it
says
the names from the previous record in the form in the delete confirmation
message box. Very strange.

Here is the code I'm using for the subform's before delete confirm event:

Private Sub Form_BeforeDelConfirm(Cancel As Integer, Response As Integer)
' Suppress default Delete Confirm dialog box.
Response = acDataErrContinue
' Display custom dialog box.
If MsgBox("Are you sure you want to remove the driver " & [First Names]
& " " & Surname & " from this vehicle?" & vbNewLine & _
, vbOKCancel) = vbCancel Then
Cancel = True
End If
End Sub

I know that by default when you delete a record, the form shows the next
record in the table or query when the before delete confirmation message
box
is displayed (even though the "current" record hasn't been deleted yet.)
Please see the post at

http://www.microsoft.com/office/comm...xp=&sloc=en-us

(or find this post, "Delete Button Shows Previous Record Before the
Current
Record is Deleted" in Access Forms in this forum.)

I imagine this is this something to do with it. Do you know a way around
this? Do I need to put the Application.Echo False into the Before Delete
Confirm code too?

Please help if you can.
TIA
Rich



  #4  
Old October 10th, 2005, 02:37 PM
Rich1234
external usenet poster
 
Posts: n/a
Default

Thanks Van

I used the delete button's on click event as you advise. It works!

"Van T. Dinh" wrote:

I think BeforeDelConfirm Event actually happens AFTER the Record(s) is
deleted from the Form buffer (but the deletion has not been propagated to
the actual Table(s). Hence, the Current Record is the one *after* the
Record which has just been deleted from the buffer.

Check Access VB Help for further info ...

For confirmation Msg, stick the MsgBox in your CommandButton_Click Event and
depending on the Response, proceed or skip the deletion code as required.

--
HTH
Van T. Dinh
MVP (Access)



"Rich1234" wrote in message
...
hi
I have a continuous subform set to AllowDeletions = true. I have a delete
button on each record in the subform. On the subform's before delete
confirm
event, I have changed the default message and have set up a custom message
instead. In this message I am including the name fields from the record
which will be deleted as additional confirmation for the user. Even
though
the correct record is deleted, this confirmation box is showing fields
(First
Names and Surname) from the next record in the form! Why is this? And
when I
click on the delete button for the very last record in the subform, it
says
the names from the previous record in the form in the delete confirmation
message box. Very strange.

Here is the code I'm using for the subform's before delete confirm event:

Private Sub Form_BeforeDelConfirm(Cancel As Integer, Response As Integer)
' Suppress default Delete Confirm dialog box.
Response = acDataErrContinue
' Display custom dialog box.
If MsgBox("Are you sure you want to remove the driver " & [First Names]
& " " & Surname & " from this vehicle?" & vbNewLine & _
, vbOKCancel) = vbCancel Then
Cancel = True
End If
End Sub

I know that by default when you delete a record, the form shows the next
record in the table or query when the before delete confirmation message
box
is displayed (even though the "current" record hasn't been deleted yet.)
Please see the post at

http://www.microsoft.com/office/comm...xp=&sloc=en-us

(or find this post, "Delete Button Shows Previous Record Before the
Current
Record is Deleted" in Access Forms in this forum.)

I imagine this is this something to do with it. Do you know a way around
this? Do I need to put the Application.Echo False into the Before Delete
Confirm code too?

Please help if you can.
TIA
Rich




 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I DELETE a CONTACT from the Contacts Folder without an Err Frustrated & Fuming in Fairview Contacts 1 July 5th, 2005 08:52 PM
deleting values in combo boxes R General Discussion 23 November 19th, 2004 02:30 PM
Delete Query Shanin Running & Setting Up Queries 14 July 31st, 2004 07:15 PM
Delete order chase General Discussion 1 June 7th, 2004 04:11 PM
Delete - confirmation required Elfie General Discussion 2 May 21st, 2004 05:51 PM


All times are GMT +1. The time now is 03:45 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.