Here is the code in the DB. It really is the only thing being used, other than an unbound textbox. The purpose is to open a form or report to a specified date criteria. The catch is the time is stored in the table's date field along with the date becuase of the default value Now().
The user inputs the desired date to apply to the Where critiria via an unbound textbox formated as Short Date to take advantage of the intrinsic date picker. The user then clicks a button. Begind the button is this code.
Code:
Dim dtReportStart As Date
Dim dtReportEnd As Date
dtReportStart = Me.txtDate.Value - 1
dtReportEnd = Me.txtDate.Value + 1
Dim strWhere As String
strWhere = "[CNORepDate] BETWEEN #" & dtReportStart & "# AND #" & dtReportEnd & "#"
DoCmd.OpenForm "frmA_A_Test", acNormal, , strWhere
However, now that I paste the code here, I see that there is a major problem with the code. It will return three days instead of one. So the appropriate way is to convert the inoput from the user into a string and concatanate the time. The start time and end time need to include the seconds as well to insure no records are orphaned.
Code:
Dim strReportStart As String
Dim strReportEnd As String
strReportStart = Me.txtDate.Value & " 12:00:00 AM"
strReportEnd = Me.txtDate.Value & " 11:59:59 PM"
Dim strWhere As String
strWhere = "[CNORepDate] BETWEEN #" & strReportStart & "# AND #" & strReportEnd & "#"
DoCmd.OpenForm "frmA_A_Test", acNormal, , strWhere