Lgvalencia
New member
- Local time
- Today, 12:41
- Joined
- Mar 8, 2023
- Messages
- 10
Me.Refresh will not help. Use Me.Requery after the Delete command.I am having the issue of my delete button saying the command or action DeleteRecord isn't available.
See attached file
Thank you
Lesley
Private Sub BDELETE_Click()
On Error GoTo Err_BDELETE_Click
Dim Response As String
Dim Cancel As Integer
Response = acDataErrContinue
If MsgBox("Delete this record?", vbYesNo, "Delete Confirmation") = vbYes Then
If MsgBox(" Are you SURE you want to delte this Record?" & vbCrLf & _
"This will permanently delete the record.", vbYesNo, "2nd Delete Confirmation") = vbYes Then
If Me.NewRecord Then Exit Sub
DoCmd.RunCommand acCmdDeleteRecord
End If
End If
Exit_BDELETE_Click:
Exit Sub
Err_BDELETE_Click:
MsgBox Error$
Resume Exit_BDELETE_Click
End Sub
Private Sub BDELETE_Click()
On Error GoTo Err_BDELETE_Click
Dim Response As String
Dim Cancel As Integer
Dim strMsg As String
If Me.NewRecord Then
Exit Sub
End If
Response = acDataErrContinue
If MsgBox("Delete this record?", vbYesNo, "Delete Confirmation",vbYesNo) = vbYes Then
strMsg = " Are you SURE you want to delete this Record?" & vbCrLf
strMsg = strMsg & "This will permanently delete the record." & vbCrLf
strMsg = strMsg & "2nd Delete Confirmation"
If MsgBox( strMsg, vbYesNo ) = vbYes Then
DoCmd.RunCommand acCmdDeleteRecord
End If
End If
Exit_BDELETE_Click:
Exit Sub
Err_BDELETE_Click:
Select Case Err.Number
Case Else
MsgBox Err.Number & " -- " & Err.Description
End Select
Resume Exit_BDELETE_Click
End Sub
Private Sub BDELETE_Click()
On Error GoTo Err_BDELETE_Click
'Dim Response As String
'Dim Cancel As Integer
'Response = acDataErrContinue
If MsgBox("Delete this record?", vbYesNo, "Delete Confirmation") = vbYes Then
If MsgBox(" Are you SURE you want to delte this Record?" & vbCrLf & _
"This will permanently delete the record.", vbYesNo, "2nd Delete Confirmation") = vbYes Then
'arnelgp
'don't Requery it will get new record therefore
'you will loose Focus of the curren record
'Me.Requery
If Me.NewRecord Then Exit Sub
With DoCmd
.SetWarnings False
.RunCommand acCmdDeleteRecord
.SetWarnings True
End With
End If
End If
Exit_BDELETE_Click:
Exit Sub
Err_BDELETE_Click:
MsgBox Error$
Resume Exit_BDELETE_Click
End Sub
This is great. I tried it and got this error messagehere is you code to test
btw, Response is Integer not string.
also Response and Cancel has nothing to do with your code, so i comment it.
Code:Private Sub BDELETE_Click() On Error GoTo Err_BDELETE_Click 'Dim Response As String 'Dim Cancel As Integer 'Response = acDataErrContinue If MsgBox("Delete this record?", vbYesNo, "Delete Confirmation") = vbYes Then If MsgBox(" Are you SURE you want to delte this Record?" & vbCrLf & _ "This will permanently delete the record.", vbYesNo, "2nd Delete Confirmation") = vbYes Then 'arnelgp 'don't Requery it will get new record therefore 'you will loose Focus of the curren record 'Me.Requery If Me.NewRecord Then Exit Sub With DoCmd .SetWarnings False .RunCommand acCmdDeleteRecord .SetWarnings True End With End If End If Exit_BDELETE_Click: Exit Sub Err_BDELETE_Click: MsgBox Error$ Resume Exit_BDELETE_Click End Sub