I have form with a date range criteria, a combo box with a list of queries to perform and a command button to run the median of a result located in a tablefrom the selected query.
I am a true beginner of code so I have pieced this together. But I don't know how to get it to perform three steps if the second query is selected. I am stumped.
I have included my code below.
Private Sub cmbQueries_AfterUpdate()
If IsNull(txtStartDate) Then
MsgBox ("Please specify a start date")
Me!txtStartDate.SetFocus
Exit Sub
End If
If IsNull(txtEndDate) Then
MsgBox ("Please specify an end date")
Me!txtEndDate.SetFocus
End If
Exit Sub
End Sub
Private Sub cmdGetMedian_Click()
On Error GoTo Err_cmdGetMedian_Click
Dim intMedian
If IsNull(cmbQuery) Then
MsgBox ("Please select the number of criteria and edit the query in design view.")
Me!cmbQuery.SetFocus
Exit Sub
End If
DoCmd.SetWarnings False
If Left(cmbQuery, 1) = "Door to Drug Interval" Then
DoCmd.OpenQuery "aqmakDoortoIVtPAStartInterval"
ElseIf Left(cmbQuery, 1) = "Onset to Door Interval" Then
DoCmd.OpenQuery "aqmakOnsettoDoorInterval"
End If
DoCmd.SetWarnings True
intMedian = DMedian("calcvalue", "tmakMedianCalcValue")
MsgBox ("The median is: " & intMedian)
Exit_cmdGetMedian_Click:
DoCmd.SetWarnings True
Exit Sub
Err_cmdGetMedian_Click:
DoCmd.SetWarnings True
MsgBox Err.Description
Resume Exit_cmdGetMedian_Click
End Sub
I am a true beginner of code so I have pieced this together. But I don't know how to get it to perform three steps if the second query is selected. I am stumped.

Private Sub cmbQueries_AfterUpdate()
If IsNull(txtStartDate) Then
MsgBox ("Please specify a start date")
Me!txtStartDate.SetFocus
Exit Sub
End If
If IsNull(txtEndDate) Then
MsgBox ("Please specify an end date")
Me!txtEndDate.SetFocus
End If
Exit Sub
End Sub
Private Sub cmdGetMedian_Click()
On Error GoTo Err_cmdGetMedian_Click
Dim intMedian
If IsNull(cmbQuery) Then
MsgBox ("Please select the number of criteria and edit the query in design view.")
Me!cmbQuery.SetFocus
Exit Sub
End If
DoCmd.SetWarnings False
If Left(cmbQuery, 1) = "Door to Drug Interval" Then
DoCmd.OpenQuery "aqmakDoortoIVtPAStartInterval"
ElseIf Left(cmbQuery, 1) = "Onset to Door Interval" Then
DoCmd.OpenQuery "aqmakOnsettoDoorInterval"
End If
DoCmd.SetWarnings True
intMedian = DMedian("calcvalue", "tmakMedianCalcValue")
MsgBox ("The median is: " & intMedian)
Exit_cmdGetMedian_Click:
DoCmd.SetWarnings True
Exit Sub
Err_cmdGetMedian_Click:
DoCmd.SetWarnings True
MsgBox Err.Description
Resume Exit_cmdGetMedian_Click
End Sub