I have a form button. I would like to add a message box that asks if you want to proceed to run a query.
Here is what I tried unsuccessfully. I called them part1 and part2 for illustration. Can you help me?
============================================
Private Sub cmdClearWeekPlanner_Click()
'part 1
If MsgBox("Do you want to erase the Week Planner?", vbYesNo) = vbYes Then
DoCmd.Close
End If
'part2
On Error GoTo Err_cmdClearWeekPlanner_Click
Dim stDocName As String
stDocName = "2012Qry Account Week Planner to NULL"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Exit_cmdClearWeekPlanner_Click:
Exit Sub
Err_cmdClearWeekPlanner_Click:
MsgBox Err.Description
Resume Exit_cmdClearWeekPlanner_Click
End Sub
Here is what I tried unsuccessfully. I called them part1 and part2 for illustration. Can you help me?
============================================
Private Sub cmdClearWeekPlanner_Click()
'part 1
If MsgBox("Do you want to erase the Week Planner?", vbYesNo) = vbYes Then
DoCmd.Close
End If
'part2
On Error GoTo Err_cmdClearWeekPlanner_Click
Dim stDocName As String
stDocName = "2012Qry Account Week Planner to NULL"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Exit_cmdClearWeekPlanner_Click:
Exit Sub
Err_cmdClearWeekPlanner_Click:
MsgBox Err.Description
Resume Exit_cmdClearWeekPlanner_Click
End Sub