I'm having real problems with this, for the last few days. It beat out the general vb forum too.
Basically I want to enter 2 dates on a form and have the program query a database and show all flights between those 2 dates. The problem is that when the value entered for the Day part of the date is over 12, the date seems to be ignored (as well as the remainder of the SQL statement).
The result is that if the day of date2 is > 12, all the dates greater than date1 are returned. Something else that's confusing the hell out of me: if txtDate1 > 12 then date2 is treated as the low date.Code:Private Sub cmdSrch_Click() date1 = txtMonth1 & "/" & txtDate1 & "/" & txtYr1 date2 = txtMonth2 & "/" & txtDate2 & "/" & txtYr2 MsgBox "Flights between " & Format(date1, "dd/mmm/yy") & " and " & Format(date2, "dd/mmm/yy") datFlights.RecordSource = "SELECT * FROM tblFlight WHERE tblFlight.DDate BETWEEN #" & date1 & "# AND #" & date2 & "# ORDER BY tblFlight.DDate" datFlights.Refresh End Sub




Reply With Quote