Private Sub cmdStatsRpt_Click()
Dim strCriteria As String
If Me.cboFindPerson & "" = "" Then
MsgBox "Person is required.", vbOKOnly
Exit Sub
End If
If IsDate(Me.txtFrom) And IsDate(Me.txtThru) Then
If Me.txtFrom <= Me.txtThru Then
strCriteria = "PersonID = " & Me.cboFindPerson ''' & " AND ReadingDate Between #" & Me.txtFrom & "# AND #" & Me.txtThru & "#"
DoCmd.OpenReport "rptBloodPressureStats", acViewPreview, , strCriteria
DoCmd.OutputTo acOutputReport, "rptBloodPressureStats", acFormatRTF, "C:\Data\UsefulDatabases\BPStats" & "-" & Me.cboFindPerson.Column(1) & ".rtf"
DoCmd.OutputTo acOutputReport, "rptBloodPressureStats", acFormatPDF, "C:\Data\UsefulDatabases\BPStats" & "-" & Me.cboFindPerson.Column(1) & ".pdf"
Else
MsgBox " From date must be <= Thru date.", vbOKOnly
Me.txtFrom.SetFocus
Exit Sub
End If
Else
MsgBox "Both From and Thru date are required.", vbOKOnly
Me.txtFrom.SetFocus
Exit Sub
End If
End Sub