edit: Correct Code:
Private Sub Command877_Click()
Dim varResponse As Variant
varResponse = MsgBox("Do you want to include Performance Indicators in your report?", vbInformation + vbYesNoCancel)
If varResponse = vbYes Then
DoCmd.RunMacro "mcrOpenReport_Pi"
ElseIf varResponse = vbNo Then
DoCmd.RunMacro "mcrOpenReport"
Exit Sub
End If
End Sub
Original Message:
Hi all,
Novice here who needs to get himself to a VBA course or 5. I've managed to scramble together a message box that has two options that need to trigger different macros in Access. Here is the code, I'm unsure as to where it is going wrong. The Message box appears to work but no Macros. It is probably something very simple to the trained eye!
Private Sub Command877_Click()
Dim ReportType As String
ReportType = MsgBox("Do you want to include Performance Indicators in your report?", vbInformation + vbYesNoCancel, "ReportType")
If (DailyReportmsgbox = vbYes) Then
DoCmd.RunMacro "mcrOpenReport_Pi"
ElseIf (DailyReportmsgbox = vbNo) Then
DoCmd.RunMacro "mcrOpenReport"
Exit Sub
End If
End Sub