richExcelforAJ
New Member
- Joined
- Jul 12, 2022
- Messages
- 4
- Office Version
- 365
- Platform
- Windows
The code below presents a yes/no MsgBox.
First Item:
When the message box appears, I click the 'No' button and the the MsgBox quickly disappears and redisplays. I click 'No' a second time and the click is accepted producing a VbMsgBoxResult of VbNo (7). Why are 2 clicks required?
Note: This does not happen with Yes, which works perfectly. Additionally, I only have the code for the click event on this button. As I tried to get this to work, I cycled through answer types of integer, string, and VbMsgBoxResult but changing types did not help.
Second Item (not that important)
When displayed the MsgBox defaults to selection of Yes, which I would like to change to default to the No button being selected. Can the default selection when the MsgBox appears be changed?
---------------------------------------------------------------------------------------------------------------
Private Sub btnDeleteAlert_Click()
Dim answeDelete, sPrompt, sMsgTitle As String
Dim nMsgAnswer As VbMsgBoxResult
sMsgTitle = "Delete " & frmPlans.frameActivityAlerts.txtBoxAlertText
sPrompt = "This action cannot be undone. Are you sure you want to continue?"
nMsgAnswer = MsgBox(sPrompt, vbYesNo, sMsgTitle)
If nMsgAnswer = vbNo Then GoTo endSub
deleteOK:
Rem sPlanFirstAlertRow sPlanLastAlertRow sSelectedAlertRow
Call getFirstLastSelectedAlertRows
endSub:
End Sub
First Item:
When the message box appears, I click the 'No' button and the the MsgBox quickly disappears and redisplays. I click 'No' a second time and the click is accepted producing a VbMsgBoxResult of VbNo (7). Why are 2 clicks required?
Note: This does not happen with Yes, which works perfectly. Additionally, I only have the code for the click event on this button. As I tried to get this to work, I cycled through answer types of integer, string, and VbMsgBoxResult but changing types did not help.
Second Item (not that important)
When displayed the MsgBox defaults to selection of Yes, which I would like to change to default to the No button being selected. Can the default selection when the MsgBox appears be changed?
---------------------------------------------------------------------------------------------------------------
Private Sub btnDeleteAlert_Click()
Dim answeDelete, sPrompt, sMsgTitle As String
Dim nMsgAnswer As VbMsgBoxResult
sMsgTitle = "Delete " & frmPlans.frameActivityAlerts.txtBoxAlertText
sPrompt = "This action cannot be undone. Are you sure you want to continue?"
nMsgAnswer = MsgBox(sPrompt, vbYesNo, sMsgTitle)
If nMsgAnswer = vbNo Then GoTo endSub
deleteOK:
Rem sPlanFirstAlertRow sPlanLastAlertRow sSelectedAlertRow
Call getFirstLastSelectedAlertRows
endSub:
End Sub