bjv211
asked on
message to confirm record deletion
I have a form with a delete record button, and i want to confirm the deletion when the user clicks it. I do not want to use the Options>edit/find>action queries b/c i also have update queries that i do not want to confirm. this would be more of an onClick yes/no event for the delete record button. here is current:
Private Sub DelRecord_Click()
On Error GoTo Err_DelRecord_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Exit_DelRecord_Click:
Exit Sub
Err_DelRecord_Click:
MsgBox Err.Description
Resume Exit_DelRecord_Click
End Sub
Private Sub DelRecord_Click()
On Error GoTo Err_DelRecord_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Exit_DelRecord_Click:
Exit Sub
Err_DelRecord_Click:
MsgBox Err.Description
Resume Exit_DelRecord_Click
End Sub
If you want to do further automation...
Select Case Msgbox "Are you sure you really really really want to delete records.", vbYesNo, "Title goes here"
Case vbYes
'User chose yes. Delete record code goes here.
Case vbNo
'User chose no. Do nothing.
End Select
Select Case Msgbox "Are you sure you really really really want to delete records.", vbYesNo, "Title goes here"
Case vbYes
'User chose yes. Delete record code goes here.
Case vbNo
'User chose no. Do nothing.
End Select
ASKER
sorry I dont know how to implement that into my existing code (i havent done it in a while) could you place it into the code?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I create a separate form that says "Do you really really really want to delete this record." and has a "Yes" and a "NO" button. The button on your original form does nothing but open the "Confirm Delete" form. If they press "NO" the form closes and returns you to the original. If you press "Yes" the deletion is executed.
I find Message Boxes somewhat confusing, but then I'm not the sharpest tack in the box!
I find Message Boxes somewhat confusing, but then I'm not the sharpest tack in the box!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I am using the toolbox to insert the delete record button and the code I posted above is what is is using. However, it is not confirming the deletion when i click it, even if document deletions is checked in options/edit/find.
ASKER
OK i modified my delete record button code to this
Private Sub DelRecord_Click()
DoCmd.RunCommand acCmdDeleteRecord
End Sub
but i'm still not getting any confirmation.
Private Sub DelRecord_Click()
DoCmd.RunCommand acCmdDeleteRecord
End Sub
but i'm still not getting any confirmation.
ASKER
i want to confirm only record deletions, not record changes, or action queries...etc. so a msgBox with this button would prob work well
by the way
Application.RunCommand acCmdDeleteRecord do the same as your 2 line
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Now: What i understand it's when you click on your button, the database dont ask you about the deletion
Question: Is the record is deleted or not?
if you have any message after you push the button, tell me about it.
Application.RunCommand acCmdDeleteRecord do the same as your 2 line
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Now: What i understand it's when you click on your button, the database dont ask you about the deletion
Question: Is the record is deleted or not?
if you have any message after you push the button, tell me about it.
ASKER
no messages, it does delete the record.
I just try someting, I suspect somewhere in you database you set the SetWarnings to false and forget to reset to true
But if you put the code I give you above in the BeforeDelConfirm event of the form, you gona have the confirmition anyway.
If you dont have, be shure you have allowdeletion set to true
and the Before Del Confirm propertie is set to [Event Procedure]
But if you put the code I give you above in the BeforeDelConfirm event of the form, you gona have the confirmition anyway.
If you dont have, be shure you have allowdeletion set to true
and the Before Del Confirm propertie is set to [Event Procedure]
ASKER
i'm getting the message: Compile Error: expected end of statement. and the SELECT line is higlighted in red.
Private Sub Form_BeforeDelConfirm(Canc el As Integer, Response As Integer)
Select Case Msgbox "Are you sure you really really really want to delete records.", vbYesNo, "Title goes here"
Case vbYes
Response = acDataErrContinue 'Delete
Case vbNo
Cancel = True 'Cancel deletion
End Select
End Sub
Private Sub Form_BeforeDelConfirm(Canc
Select Case Msgbox "Are you sure you really really really want to delete records.", vbYesNo, "Title goes here"
Case vbYes
Response = acDataErrContinue 'Delete
Case vbNo
Cancel = True 'Cancel deletion
End Select
End Sub
Excuse me, this part was not my code just put parenthesis as follow
Select Case MsgBox("Are you sure you really really really want to delete records.", vbYesNo, "Title goes here")
Select Case MsgBox("Are you sure you really really really want to delete records.", vbYesNo, "Title goes here")
ASKER
ok, this is what I have:
Private Sub Form_BeforeDelConfirm(Canc el As Integer, Response As Integer)
Select Case MsgBox("Are you sure you really really really want to delete records.", vbYesNo, "Confirm Record Delete")
Case vbYes
Response = acDataErrContinue 'Delete
Case vbNo
Cancel = True 'Cancel deletion
End Select
End Sub
and the button is
Private Sub DelRecord_Click()
On Error GoTo Err_DelRecord_Click
Application.RunCommand acCmdDeleteRecord 'delete the record in form
Exit_DelRecord_Click:
Exit Sub
Err_DelRecord_Click:
MsgBox Err.Description
Resume Exit_DelRecord_Click
End Sub
still no message, just deletes the records.
Private Sub Form_BeforeDelConfirm(Canc
Select Case MsgBox("Are you sure you really really really want to delete records.", vbYesNo, "Confirm Record Delete")
Case vbYes
Response = acDataErrContinue 'Delete
Case vbNo
Cancel = True 'Cancel deletion
End Select
End Sub
and the button is
Private Sub DelRecord_Click()
On Error GoTo Err_DelRecord_Click
Application.RunCommand acCmdDeleteRecord 'delete the record in form
Exit_DelRecord_Click:
Exit Sub
Err_DelRecord_Click:
MsgBox Err.Description
Resume Exit_DelRecord_Click
End Sub
still no message, just deletes the records.
is there a way you can ship me your database?, it will take me 5 minutes to solve that probleme
Are you shure the Before Del Confirm propertie is set to [Event Procedure] and when you click on the ... button you see the code?
Are you shure the Before Del Confirm propertie is set to [Event Procedure] and when you click on the ... button you see the code?
ASKER
i am sure of both, how would i send it?
if it is a secure db with .mdw file, ship me everyting, front back and secure file
zip before please because my server refuse .mdb file
do you have access to a hotmail or someting like that, because my server dont give me access to that kind of e-mail and I dont whant to give you my business e-mail from this site
If you give me your e-mail, i will give you mine back to this adress
zip before please because my server refuse .mdb file
do you have access to a hotmail or someting like that, because my server dont give me access to that kind of e-mail and I dont whant to give you my business e-mail from this site
If you give me your e-mail, i will give you mine back to this adress
ASKER
i will post it here: http://trappedinnyc.com/badDB.zip
ASKER
i've unsecured it for you purposes and removed any sensitive data
It's not unsecure i'm not able to open any object
ASKER
do yo umean theres no menu? thats just a starup feature...hold shift when you open it
no i'm not able to open any object in the database
be sure you follow this:
34. How can I "de-secure" a database?
You must have Administer permissions and/or be a member of the Admins group in the workgroup information file that the database was secured with. Grant full permissions to the Users group and the Admin user account. Put the Admin user back in the Admins group and remove the password from the Admin user. You will not be prompted for a logon ID and password once the password is removed from the Admin user. Optionally, you can also run the Security Wizard again to transfer ownership of all objects back to the Admin user, but the wizard will also remove permissions from the Users group, which you may not want.
be sure you follow this:
34. How can I "de-secure" a database?
You must have Administer permissions and/or be a member of the Admins group in the workgroup information file that the database was secured with. Grant full permissions to the Users group and the Admin user account. Put the Admin user back in the Admins group and remove the password from the Admin user. You will not be prompted for a logon ID and password once the password is removed from the Admin user. Optionally, you can also run the Security Wizard again to transfer ownership of all objects back to the Admin user, but the wizard will also remove permissions from the Users group, which you may not want.
ASKER
ok this is a little ridiculous...i will find other means and award the points
Thats what I think to.
But any time if you dont find the way, ship me your db and I will be glad to help you
I,m shure it's a simple thing
Try the code in a brand new database to see if it the database or someting else....
OK Bye Bye
But any time if you dont find the way, ship me your db and I will be glad to help you
I,m shure it's a simple thing
Try the code in a brand new database to see if it the database or someting else....
OK Bye Bye
DoCmd.SetWarnings False '<--- Does not prompt user with 'You are about to delete a record' message