Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Visual Basic -Data access ,Data missing

Visual Basic -Data access ,Data missing

Scheduled Pinned Locked Moved Visual Basic
databasequestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rajesh Rajan Pankapattu
    wrote on last edited by
    #1

    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 ?

    C C 2 Replies Last reply
    0
    • R Rajesh Rajan Pankapattu

      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 ?

      C Offline
      C Offline
      ciacia
      wrote on last edited by
      #2

      IF the output is comming like what you have shown then try saving the databas table bafre running the progam and also close the table and then check tha out put. See if it works .:-D

      1 Reply Last reply
      0
      • R Rajesh Rajan Pankapattu

        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 ?

        C Offline
        C Offline
        cutequencher
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups