Visual Basic -Data access ,Data missing
-
The folowing is a Table and it's data of an MS Access Database Table: EXPENSES EDATE(Date) ETYPE(String) AMOUNT(Currency) --------------------------------------------- 01/01/07 Electricty 1000 21/01/07 Phone 1500 24/01/07 Repair 2000 05/02/07 Electricty 1000 23/02/07 Phone 1500 --------------------------------------------- Controls used on the VB form are... ------------------------------------- Data Control named Data1 DBGrid named db1, It's Data source set to Data1 DatePickers named DTPicker1 and DTPicker2 Command Button named CmdExp Running the code ---------------- DatePicker1 set to 01/01/07 and DatePicker2 set to 21/03/07 Following is the code executed when CmdExp is Clicked... -------------------------------------------------------------- Private Sub CmdExp_Click() Dim rs_exp As Recordset Set rs_exp = db.OpenRecordset("select * from EXPENSES where EDATE >= " & DTPicker1.Value & " and EDATE <=" & DTPicker2.Value & " ") Set Data1.Recordset = rs_exp End Sub The OutPut is ------------- 01/01/07 Electricty 1000 21/01/07 Phone 1500 05/02/07 Electricty 1000 Why does the two records with date 24/01/07 and 23/02/07 is not displayed even though they are between the two date ranges ?
-
The folowing is a Table and it's data of an MS Access Database Table: EXPENSES EDATE(Date) ETYPE(String) AMOUNT(Currency) --------------------------------------------- 01/01/07 Electricty 1000 21/01/07 Phone 1500 24/01/07 Repair 2000 05/02/07 Electricty 1000 23/02/07 Phone 1500 --------------------------------------------- Controls used on the VB form are... ------------------------------------- Data Control named Data1 DBGrid named db1, It's Data source set to Data1 DatePickers named DTPicker1 and DTPicker2 Command Button named CmdExp Running the code ---------------- DatePicker1 set to 01/01/07 and DatePicker2 set to 21/03/07 Following is the code executed when CmdExp is Clicked... -------------------------------------------------------------- Private Sub CmdExp_Click() Dim rs_exp As Recordset Set rs_exp = db.OpenRecordset("select * from EXPENSES where EDATE >= " & DTPicker1.Value & " and EDATE <=" & DTPicker2.Value & " ") Set Data1.Recordset = rs_exp End Sub The OutPut is ------------- 01/01/07 Electricty 1000 21/01/07 Phone 1500 05/02/07 Electricty 1000 Why does the two records with date 24/01/07 and 23/02/07 is not displayed even though they are between the two date ranges ?
-
The folowing is a Table and it's data of an MS Access Database Table: EXPENSES EDATE(Date) ETYPE(String) AMOUNT(Currency) --------------------------------------------- 01/01/07 Electricty 1000 21/01/07 Phone 1500 24/01/07 Repair 2000 05/02/07 Electricty 1000 23/02/07 Phone 1500 --------------------------------------------- Controls used on the VB form are... ------------------------------------- Data Control named Data1 DBGrid named db1, It's Data source set to Data1 DatePickers named DTPicker1 and DTPicker2 Command Button named CmdExp Running the code ---------------- DatePicker1 set to 01/01/07 and DatePicker2 set to 21/03/07 Following is the code executed when CmdExp is Clicked... -------------------------------------------------------------- Private Sub CmdExp_Click() Dim rs_exp As Recordset Set rs_exp = db.OpenRecordset("select * from EXPENSES where EDATE >= " & DTPicker1.Value & " and EDATE <=" & DTPicker2.Value & " ") Set Data1.Recordset = rs_exp End Sub The OutPut is ------------- 01/01/07 Electricty 1000 21/01/07 Phone 1500 05/02/07 Electricty 1000 Why does the two records with date 24/01/07 and 23/02/07 is not displayed even though they are between the two date ranges ?
first, it is much better to use "between" instead of the greater than and equal... second, maybe because of a time issue make your two dates boundless to time... format it and parse it as date.