G
Guest
I am using a "Martin Green" template and have tried to customize it for
myself. There is something I have changed with the dates or something that
has made it not filter properly. I was not sure on the format for sending
dates in the filter in a report. I would like the form to open the report
then apply the filter. I tried docmd.openreport (rptFindings,acPreview)
without luck. Thanks for any suggestions in advance!
Private Sub Cancel_Click()
On Error Resume Next
' Switch the filter off
Reports![rptFindings].FilterOn = False
End Sub
Private Sub OK_Click()
Dim beginnningdate As String
Dim EndingDate As String
Dim strfindtech As String
Dim strfindscribe As String
Dim strfindexamdate As String
Dim strfindauditmonth As String
Dim strfindpatname As String
Dim strfindenteredby As String
strbeginningdate = ">=#" & Me.beginningdate.Value & "#"
strEndingDate = "<=#" & Me.EndingDate.Value & "#"
' Check that the report is open
If SysCmd(acSysCmdGetObjectState, acReport, "rptFindings") <>
acObjStateOpen Then
MsgBox "You must open the report first."
Exit Sub
End If
' Build criteria string for Technician Name field
If IsNull(Me.findtech.Value) Then
strfindtech = "Like '*'"
Else
strfindtech = "='" & Me.findtech.Value & "'"
End If
' Build criteria string for Scribe Name field
If IsNull(Me.findscribe.Value) Then
strfindscribe = "Like '*'"
Else
strfindscribe = "='" & Me.findscribe.Value & "'"
End If
' Build criteria string for Examdate field
If IsNull(Me.findexamdate.Value) Then
strfindexamdate = "Like '*'"
Else
strfindexamdate = "=#" & Me.findexamdate.Value & "#"
End If
' Build criteria string for Auditmonth field
If IsNull(Me.findauditmonth.Value) Then
strfindauditmonth = "Like '*'"
Else
strfindauditmonth = "=#" & Me.findauditmonth.Value & "#"
End If
' Build criteria string for Patient Name field
If IsNull(Me.findpatname.Value) Then
strfindpatname = "Like '*'"
Else
strfindpatname = "='" & Me.findpatname.Value & "'"
End If
' Build criteria string for Enteredby field
If IsNull(Me.findenteredby.Value) Then
strfindenteredby = "Like '*'"
Else
strfindenteredby = "='" & Me.findenteredby.Value & "'"
End If
' Combine criteria strings into a WHERE clause for the filter
strFilter = "[DateofEntry] " & strbeginningdate & " AND [Dateofentry] " &
strEndingDate & " AND [Technician Name] " & strfindtech & " AND [Scribe Name]
" & strfindscribe & " AND [Examdate] " & strfindexamdate & " AND [Patient
Name] " & strfindpatname & " AND [Auditmonth] " & strfindauditmonth & " AND
[Enteredby] " & strfindenteredby
' Apply the filter and switch it on
With Reports![rptFindings]
.Filter = strFilter
.FilterOn = True
End With
End Sub
myself. There is something I have changed with the dates or something that
has made it not filter properly. I was not sure on the format for sending
dates in the filter in a report. I would like the form to open the report
then apply the filter. I tried docmd.openreport (rptFindings,acPreview)
without luck. Thanks for any suggestions in advance!
Private Sub Cancel_Click()
On Error Resume Next
' Switch the filter off
Reports![rptFindings].FilterOn = False
End Sub
Private Sub OK_Click()
Dim beginnningdate As String
Dim EndingDate As String
Dim strfindtech As String
Dim strfindscribe As String
Dim strfindexamdate As String
Dim strfindauditmonth As String
Dim strfindpatname As String
Dim strfindenteredby As String
strbeginningdate = ">=#" & Me.beginningdate.Value & "#"
strEndingDate = "<=#" & Me.EndingDate.Value & "#"
' Check that the report is open
If SysCmd(acSysCmdGetObjectState, acReport, "rptFindings") <>
acObjStateOpen Then
MsgBox "You must open the report first."
Exit Sub
End If
' Build criteria string for Technician Name field
If IsNull(Me.findtech.Value) Then
strfindtech = "Like '*'"
Else
strfindtech = "='" & Me.findtech.Value & "'"
End If
' Build criteria string for Scribe Name field
If IsNull(Me.findscribe.Value) Then
strfindscribe = "Like '*'"
Else
strfindscribe = "='" & Me.findscribe.Value & "'"
End If
' Build criteria string for Examdate field
If IsNull(Me.findexamdate.Value) Then
strfindexamdate = "Like '*'"
Else
strfindexamdate = "=#" & Me.findexamdate.Value & "#"
End If
' Build criteria string for Auditmonth field
If IsNull(Me.findauditmonth.Value) Then
strfindauditmonth = "Like '*'"
Else
strfindauditmonth = "=#" & Me.findauditmonth.Value & "#"
End If
' Build criteria string for Patient Name field
If IsNull(Me.findpatname.Value) Then
strfindpatname = "Like '*'"
Else
strfindpatname = "='" & Me.findpatname.Value & "'"
End If
' Build criteria string for Enteredby field
If IsNull(Me.findenteredby.Value) Then
strfindenteredby = "Like '*'"
Else
strfindenteredby = "='" & Me.findenteredby.Value & "'"
End If
' Combine criteria strings into a WHERE clause for the filter
strFilter = "[DateofEntry] " & strbeginningdate & " AND [Dateofentry] " &
strEndingDate & " AND [Technician Name] " & strfindtech & " AND [Scribe Name]
" & strfindscribe & " AND [Examdate] " & strfindexamdate & " AND [Patient
Name] " & strfindpatname & " AND [Auditmonth] " & strfindauditmonth & " AND
[Enteredby] " & strfindenteredby
' Apply the filter and switch it on
With Reports![rptFindings]
.Filter = strFilter
.FilterOn = True
End With
End Sub