I have one form with two date pickers and some buttons to open certain reports. It seems that if one of the dates is set to the 1st through 7th and 9th through 12th of a month, the filter just doesn't work at all, but any other dates and it works as it should. Has anyone else ever had this problem? Its in several spots of the same database. I have another form that just searches through the records on the form with an unbound date picker in the header and it does the same thing.
Thanks in advance for any help!
Heres some of the code I have, the rest is pretty similar:
Private Sub Command30_Click()
Dim db As Database
Dim rs1 As Recordset
Dim rs2 As Recordset
Dim txtFirstDate As Date
Dim txtLastDate As Date
Dim strWhere As String
Const conDateFormat = "\#mm\/dd\/yyyy\#"
Set db = CurrentDb
Set rs1 = db.OpenRecordset("Training")
Set rs2 = db.OpenRecordset("TrainingCodes")
If IsNull(Me.FirstDate) Or IsNull(Me.LastDate) Then
MsgBox "Please Pick Both Dates!"
Cancel = True
Else
If Me.LastDate > Me.FirstDate Then
txtFirstDate = Me.FirstDate
txtLastDate = Me.LastDate
Else
txtFirstDate = Me.LastDate
txtLastDate = Me.FirstDate
End If
strWhere = "CourseDate >= #" & txtFirstDate & "# And CourseDate <= #" & txtLastDate & "#"
DoCmd.OpenReport "TrainingOverview", acViewReport, , strWhere, acWindowNormal, OpenArgs
End If
Debug.Print Me.FirstDate
Debug.Print Me.LastDate
rs1.Close
rs2.Close
Set rs1 = Nothing
Set rs2 = Nothing
db.Close
End Sub