ineedyourhelp
MIS
I have created a form with start and end date parameters with the following code (see below)....(Taken from an Allen Browne article "Limiting a Report To a Date Range" in a previous post)
The function operates as it should, but I was wondering if there was a way to tweak it so it would...
1. Show me all dates within a date range instead of between a date range.
Example:
If I enter a Start Date 7-1-2004 and an end date of 7-14-04, I would like all records returned within those ranges (7-1-04 through 7-14-04) With the below, it only returns what is between these two dates (7-2-04 through 7-13-04 data is returned)
2. Return all data if Start and End Date fields are left blank
3. Return 1 day's worth of data if same day is used in Start and End Date.
Example: If I want only 7-14-04 data, I would enter a Start Date as 7-14-04 and an End Date as 7-14-04. Right now, if I enter it that way, it returns nothing.
Any help would be appreciated.
SEE CODE BELOW.................
Dim strReport As String 'Name of report to open.
Dim strField As String 'Name of your date field.
Dim strWhere As String 'Where condition for OpenReport.
Const conDateFormat = "\#mm\/dd\/yyyy\#"
strReport = "Completed Issues"
strField = "[Date/Time Completed]"
If IsNull(Me.txtStartDate) Then
If Not IsNull(Me.txtEndDate) Then 'End date, but no start.
strWhere = strField & " < " & Format(Me.txtEndDate, conDateFormat)
End If
Else
If IsNull(Me.txtEndDate) Then 'Start date, but no End.
strWhere = strField & " > " & Format(Me.txtStartDate, conDateFormat)
Else 'Both start and end dates.
strWhere = strField & " between " & Format(Me.txtStartDate, conDateFormat) _
& " And " & Format(Me.txtEndDate, conDateFormat)
End If
The function operates as it should, but I was wondering if there was a way to tweak it so it would...
1. Show me all dates within a date range instead of between a date range.
Example:
If I enter a Start Date 7-1-2004 and an end date of 7-14-04, I would like all records returned within those ranges (7-1-04 through 7-14-04) With the below, it only returns what is between these two dates (7-2-04 through 7-13-04 data is returned)
2. Return all data if Start and End Date fields are left blank
3. Return 1 day's worth of data if same day is used in Start and End Date.
Example: If I want only 7-14-04 data, I would enter a Start Date as 7-14-04 and an End Date as 7-14-04. Right now, if I enter it that way, it returns nothing.
Any help would be appreciated.
SEE CODE BELOW.................
Dim strReport As String 'Name of report to open.
Dim strField As String 'Name of your date field.
Dim strWhere As String 'Where condition for OpenReport.
Const conDateFormat = "\#mm\/dd\/yyyy\#"
strReport = "Completed Issues"
strField = "[Date/Time Completed]"
If IsNull(Me.txtStartDate) Then
If Not IsNull(Me.txtEndDate) Then 'End date, but no start.
strWhere = strField & " < " & Format(Me.txtEndDate, conDateFormat)
End If
Else
If IsNull(Me.txtEndDate) Then 'Start date, but no End.
strWhere = strField & " > " & Format(Me.txtStartDate, conDateFormat)
Else 'Both start and end dates.
strWhere = strField & " between " & Format(Me.txtStartDate, conDateFormat) _
& " And " & Format(Me.txtEndDate, conDateFormat)
End If