Actions from MsgBox

  • Thread starter Thread starter Anna
  • Start date Start date
A

Anna

Hi,

I have a message box that shows when a button is clicked
on a form - how can I perform functions based on what
option is chosen?
For example, if "yes" is clicked, open frmData, if "no" is
clicked, close message box

Here is the code I have for the message box:

Private Sub cmdOpenDataForm_Click()
Dim intAnswer As Integer
intAnswer = MsgBox("Do you want to add new data?"
vbYesNoCancel + vbQuestion, _
"Enquiry")
End Sub

Thanks for any help,

Anna
 
If intAnswer = vbYes Then
'Open Yes Form
ElseIf intAnswer = vbNo Then
'Open No Form
End If
 
Back
Top