469,331 Members | 6,696 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,331 developers. It's quick & easy.

BeforeDelConfirm stopped working

Hi,
I had this perfectly working form "Patients" where I had a custom delete confirmation in BeforeDelConfirm event. But suddenly I found out that the delete confirmation is not working. I have no clue what went wrong. I put a Debug.Print in the BeforeDelConfirm sub to see if it fires at all. As I guessed it is not fired and delete command continues without confirmation.

I created a new form "Patients1" using access wizard where the delete confirmation works fine.

I am using Access 2010 and accdb format. I have attached the my database. Please help me to resolve this issue.

Thanks,
Robin
Attached Files
File Type: zip btf.zip (126.9 KB, 104 views)
Sep 16 '10 #1
7 3299
I figured out that I have converted the ID field from integer to text (PT0001,PT0002,..) which caused the problem. But do not find any apparent reason how it may cause the problem.

I tested with entering numeric Id in the table and delete confirmation works. Please help.
Sep 16 '10 #2
NeoPa
32,182 Expert Mod 16PB
You'll need to post some more information Robin. There are no details about any relevant design issues. Posting an attachment is not to be relied on. The question needs to be fully explained in the text.

PS. Even those who do open attachments largely require them to be in 2003 or earlier format. Even a readable attachment though, cannot be considered as fitting in place of a properly worded question. Only as further clarification at best, or to give an opportunity for seeing the problem for themselves. Never as part of the question. Never an excuse for missing out important detail in the question.

PPS. It's just the sort of thing that will cause a thread to remain unanswered. A clearly described question is very much more likely to garner responses.
Sep 20 '10 #3
patjones
931 Expert 512MB
I'm going to go along with NeoPa here and ask you to post the code. I've looked at attachments for other threads, however that has been in cases where all else failed. There could be something simple in your code that we can just pick out immediately. Thanks.

Pat
Sep 20 '10 #4
Thank you NeoPa and Pat.

Firstly, let me tell you this is my first project in Access. I wrote the following Delete_Click sub to delete records in form Patients. I wanted a custom delete confirmation, so I added the BeforeDelConfirm event. Until this point everything working in order when I decided to change the Id field from numeric to text (PT0001, PT0002,..) and made the changes in the code accordingly. But I found records are deleted without the confirmation msg. Incidentally I discovered that if I use a numeric value as Id instead of text, it shows the confirmation msg. I am totally clueless about this behavior as there is no reference to Id field in any of these functions.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Delete_Click()
  2.     On Error GoTo ErrorHandler:
  3.     Screen.PreviousControl.SetFocus
  4.  
  5.     If Not Me.NewRecord Then
  6.         RunCommand acCmdDeleteRecord
  7.     End If
  8.  
  9.     If Me.NewRecord And Not Me.Dirty Then
  10.         RunCommand acCmdRecordsGoToLast
  11.     End If
  12.  
  13.     If Me.NewRecord And Me.Dirty Then
  14.         RunCommand acCmdUndo
  15.         RunCommand acCmdRecordsGoToLast
  16.     End If
  17.     Exit Sub
  18.  
  19. ErrorHandler:
  20.     If Err.Number = 2501 Then 'Catches the error raised by cancelling DoCmd action
  21.         Err.Clear
  22.     Else
  23.         MsgBox "Error # " & Err.Number & vbCrLf & _
  24.                 vbCrLf & Err.Description
  25.         Beep
  26.     End If
  27. End Sub
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeDelConfirm(Cancel As Integer, Response As Integer)
  2.     Dim strMessage As String
  3.     Dim intResponse As Integer
  4.     On Error GoTo ErrorHandler:
  5.     strMessage = "Are you sure, you want to delete the current record?"
  6.     intResponse = MsgBox(strMessage, vbYesNo + vbQuestion, "Continue delete?")
  7.  
  8.     If intResponse = vbYes Then
  9.         Response = acDataErrContinue
  10.     Else
  11.         Cancel = True
  12.     End If
  13.     Exit Sub
  14.  
  15. ErrorHandler:
  16.     MsgBox "Error # " & Err.Number & vbCrLf & _
  17.             vbCrLf & Err.Description
  18.  
  19. End Sub
I hope I could clarify the question.

Thanks,
Robin
Sep 20 '10 #5
patjones
931 Expert 512MB
I set your situation up in my test database and found the same thing...that the before delete event is not firing. No time to research further right now but I certainly am going to look into it.

Pat
Sep 20 '10 #6
patjones
931 Expert 512MB
Robin,

I apologize for the delay. I'm not sure if you managed to resolve this issue. I discovered that the BeforeDelConfirm event will not fire if the the Confirm Record Changes box is cleared under Access Options. When I set that option and tried it again, the event fired properly.

Give it a try and let us know. If it doesn't work, we can look into it further.

Pat
Sep 24 '10 #7
Hi Pat,
Thanks for ur reply. The bizarre thing which I had also mentioned earlier is that if I use a numeric value as Id instead of text, it shows the confirmation msg. If "Confirm Record Changes" is unchecked it shouldn't fire at all. Anyway I have checked in the settings and found alright.

Robin
Sep 24 '10 #8

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by vzaffiro | last post: by
reply views Thread by Oenone | last post: by
2 posts views Thread by Rico | last post: by
1 post views Thread by rickcasey | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by haryvincent176 | last post: by
reply views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.