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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Dialog box prevents record deleting
I have a database with standard record function buttons. However, my 'Delete'
button seems to have a problem. When I add vb code to bring up a custom dialgog asking the user whether they definitely wish to delete the current record, nothing happens after it. However, when I remove the dialog box code, the record deletes immediately the button is pressed. My code is as follows: x = MsgBox("Are you sure you wish to delete the current record?", vbYesNo + vbExclamation) If x = vbNo Then Exit Sub Else DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70 DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70 End If Any ideas |
#2
|
|||
|
|||
Dialog box prevents record deleting
Can anyone help please? This is really holding me up with my project now
"Rich Stone" wrote: I have a database with standard record function buttons. However, my 'Delete' button seems to have a problem. When I add vb code to bring up a custom dialog asking the user whether they definitely wish to delete the current record, nothing happens after it. However, when I remove the dialog box code, the record deletes immediately the button is pressed. My code is as follows: x = MsgBox("Are you sure you wish to delete the current record?", vbYesNo + vbExclamation) If x = vbNo Then Exit Sub Else DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70 DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70 End If Any ideas |
#3
|
|||
|
|||
Dialog box prevents record deleting
On Thu, 17 Sep 2009 04:57:02 -0700, Rich Stone
wrote: I have a database with standard record function buttons. However, my 'Delete' button seems to have a problem. When I add vb code to bring up a custom dialgog asking the user whether they definitely wish to delete the current record, nothing happens after it. However, when I remove the dialog box code, the record deletes immediately the button is pressed. My code is as follows: x = MsgBox("Are you sure you wish to delete the current record?", vbYesNo + vbExclamation) If x = vbNo Then Exit Sub Else DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70 DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70 End If Any ideas Can you verify that the user is indeed clicking the Yes button? Do note that this code is seriously obsolete (the wizards are stuck back in the last century). I'd suggest Private Sub cmdDelete_Click() Dim iAns As Integer iAns = MsgBox("Are you sure you wish to delete the current record?", _ vbYesNo + vbExclamation) If iAns = vbYes Then DoCmd.RunCommand acCmdDeleteRecord End If End Sub Try putting a breakpoint on your x= line (in the VBA editor click in the grey bar on the left of the editing window) and step through the code to see if something unexpected is happning; also be sure you don't have SetWarnings set to False somewhere (it would suppress warning messages about failed deletes). -- John W. Vinson [MVP] |
#4
|
|||
|
|||
Dialog box prevents record deleting
Rich
Are you using an MS Access "dialog" box, or are you referring to the message box (MsgBox(...))? How are you confirming that the row is not deleted? Regards Jeff Boyce Microsoft Office/Access MVP "Rich Stone" wrote in message ... I have a database with standard record function buttons. However, my 'Delete' button seems to have a problem. When I add vb code to bring up a custom dialgog asking the user whether they definitely wish to delete the current record, nothing happens after it. However, when I remove the dialog box code, the record deletes immediately the button is pressed. My code is as follows: x = MsgBox("Are you sure you wish to delete the current record?", vbYesNo + vbExclamation) If x = vbNo Then Exit Sub Else DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70 DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70 End If Any ideas |
#5
|
|||
|
|||
Dialog box prevents record deleting
Thank you for your replies.
The button is on a form that shows each record at a time. I originally used the wizard to create the delete button, hence the old coding. However, I did change it to the revised method. I also have warnings off as I am using custom dialog throughout the database. The button works perfectly until I put the code in for the confirmation box which doesn't make any sense as I've done this everywhere else in the database with no problems at all. I will first try turning the warnings back on. Then I will try to step through the code and see what is happening. I have error catching in place but there aren't any coming up! "Jeff Boyce" wrote: Rich Are you using an MS Access "dialog" box, or are you referring to the message box (MsgBox(...))? How are you confirming that the row is not deleted? Regards Jeff Boyce Microsoft Office/Access MVP "Rich Stone" wrote in message ... I have a database with standard record function buttons. However, my 'Delete' button seems to have a problem. When I add vb code to bring up a custom dialgog asking the user whether they definitely wish to delete the current record, nothing happens after it. However, when I remove the dialog box code, the record deletes immediately the button is pressed. My code is as follows: x = MsgBox("Are you sure you wish to delete the current record?", vbYesNo + vbExclamation) If x = vbNo Then Exit Sub Else DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70 DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70 End If Any ideas |
#6
|
|||
|
|||
Dialog box prevents record deleting
Thanks for your help. Please have a look at my other reply below.
"John W. Vinson" wrote: On Thu, 17 Sep 2009 04:57:02 -0700, Rich Stone wrote: I have a database with standard record function buttons. However, my 'Delete' button seems to have a problem. When I add vb code to bring up a custom dialgog asking the user whether they definitely wish to delete the current record, nothing happens after it. However, when I remove the dialog box code, the record deletes immediately the button is pressed. My code is as follows: x = MsgBox("Are you sure you wish to delete the current record?", vbYesNo + vbExclamation) If x = vbNo Then Exit Sub Else DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70 DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70 End If Any ideas Can you verify that the user is indeed clicking the Yes button? Do note that this code is seriously obsolete (the wizards are stuck back in the last century). I'd suggest Private Sub cmdDelete_Click() Dim iAns As Integer iAns = MsgBox("Are you sure you wish to delete the current record?", _ vbYesNo + vbExclamation) If iAns = vbYes Then DoCmd.RunCommand acCmdDeleteRecord End If End Sub Try putting a breakpoint on your x= line (in the VBA editor click in the grey bar on the left of the editing window) and step through the code to see if something unexpected is happning; also be sure you don't have SetWarnings set to False somewhere (it would suppress warning messages about failed deletes). -- John W. Vinson [MVP] |
Thread Tools | |
Display Modes | |
|
|