J
Jeffshex
I have code that works already, with the exception of a date range. In the
database there is a field named BarDate that I want to run a query on. My
current form has code where if a field is blank on the form when you hit the
Apply Filter button, it uses the * to grab all of the info. I need help
implemeting the date part, which i cannot figure out. I'd like to have it
where if the leave the StartDate and
EndDate blank it shows everything, otherwise if those fields are filled in,
I'd like the query to insert the Between & And clause.
Any Ideas???
Here is the current code that works perfect...minus the date part
Private Sub cmdApplyFilter_Click()
' Declare variables for query string
Dim strServer As String
Dim strAdmin As String
Dim strPriority As String
Dim strRequestType As String
Dim dtmStartDate As Date
Dim dtmEndDate As Date
Dim strRequestName As String
Dim strFilter As String
' These IF statements tell the query to show all records if the selection is
left blank.
If IsNull(Me.cboServerName.Value) Then
strServer = "Like '*'"
Else
strServer = "='" & Me.cboServerName.Value & "'"
End If
If IsNull(Me.cboSysAdminName.Value) Then
strAdmin = "Like '*'"
Else
strAdmin = "='" & Me.cboSysAdminName.Value & "'"
End If
If IsNull(Me.cboPriority.Value) Then
strPriority = "Like '*'"
Else
strPriority = "='" & Me.cboPriority.Value & "'"
End If
If IsNull(Me.cboRequestType.Value) Then
strRequestType = "Like '*'"
Else
strRequestType = "='" & Me.cboRequestType.Value & "'"
End If
If IsNull(Me.cboRequestName.Value) Then
strRequestName = "Like '*'"
Else
strRequestName = "='" & Me.cboRequestName.Value & "'"
End If
strFilter = "[ServerName] " & strServer & " AND [RequestName] " &
strRequestName & " And [RequestType] " & strRequestType & " AND
[SysAdminName] " & strAdmin & " AND [Priority] " & strPriority & " "
With Reports![rptBAR]
.Filter = strFilter
.FilterOn = True
End With
End Sub
database there is a field named BarDate that I want to run a query on. My
current form has code where if a field is blank on the form when you hit the
Apply Filter button, it uses the * to grab all of the info. I need help
implemeting the date part, which i cannot figure out. I'd like to have it
where if the leave the StartDate and
EndDate blank it shows everything, otherwise if those fields are filled in,
I'd like the query to insert the Between & And clause.
Any Ideas???
Here is the current code that works perfect...minus the date part
Private Sub cmdApplyFilter_Click()
' Declare variables for query string
Dim strServer As String
Dim strAdmin As String
Dim strPriority As String
Dim strRequestType As String
Dim dtmStartDate As Date
Dim dtmEndDate As Date
Dim strRequestName As String
Dim strFilter As String
' These IF statements tell the query to show all records if the selection is
left blank.
If IsNull(Me.cboServerName.Value) Then
strServer = "Like '*'"
Else
strServer = "='" & Me.cboServerName.Value & "'"
End If
If IsNull(Me.cboSysAdminName.Value) Then
strAdmin = "Like '*'"
Else
strAdmin = "='" & Me.cboSysAdminName.Value & "'"
End If
If IsNull(Me.cboPriority.Value) Then
strPriority = "Like '*'"
Else
strPriority = "='" & Me.cboPriority.Value & "'"
End If
If IsNull(Me.cboRequestType.Value) Then
strRequestType = "Like '*'"
Else
strRequestType = "='" & Me.cboRequestType.Value & "'"
End If
If IsNull(Me.cboRequestName.Value) Then
strRequestName = "Like '*'"
Else
strRequestName = "='" & Me.cboRequestName.Value & "'"
End If
strFilter = "[ServerName] " & strServer & " AND [RequestName] " &
strRequestName & " And [RequestType] " & strRequestType & " AND
[SysAdminName] " & strAdmin & " AND [Priority] " & strPriority & " "
With Reports![rptBAR]
.Filter = strFilter
.FilterOn = True
End With
End Sub