Query a date from database


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 1 of 1

Thread: Query a date from database

Hybrid View

  1. #1
    Join Date
    May 2007
    Posts
    1

    Query a date from database

    I am still finding the best solution.. I have join many forums but did not find a best place to answer the question. I attach a sample code


    I have planting date, and I use DTpicker. I chose to plant the crop on 12/03/2007 (txtDate = Format(DTPicker1.Value, "dd/mm/yyyy")
    And it list me the activities from the datasource (DBMS.MDB). You can see that, it list the activities with date in the listview before the planning date (12/03/2007 ). This activities, I should do before the planting date arrive.


    From the list, you can see 26/01/2007 is the starting date for activities 1 and it took 7 days to finish this activities. The date expected to finish is on 1/02/2007

    (26/01/2007,27/01/2007,28/01/2007,29/01/2007,30/01/2007,31/01/2007,1/02/2007)

    The second activities start on 2/2/2007 and expected to finish on 4/2/2007 (2/02/2007,3/02/2007,4/2/2007) and it take 3 days to finish and so on...

    From the list, I want to do a query:-

    My Question is, I want to do a query to find what activities I should do for the spesific date base on the list.Let say, I query date 30/01/2007, Then It list the activities in a new listview. From the listview, It show me the result and it support in activities 1.

    I have create a new dtpicker and the listview to show the result form the query.Have an idea?I have trouble to do a query by date.

    I use ADODB connection and microsoft access

    Code for listview


    Public Sub AddLvItem()
    On Error Resume Next
    Dim newDate As Date
    rec.MoveFirst
    Do Until rec.EOF
    If rec("hari") = "" Then
    Set lvItem = lvJadual.ListItems.Add(, , "")
    lvItem.ListSubItems.Add , , "" & rec("peruntukan")
    lvItem.ListSubItems.Add , , "" & rec("aktiviti")
    lvItem.ListSubItems.Add , , "" & rec("sasaran")
    lvItem.ListSubItems.Add , , "" & rec("jenisinput")
    lvItem.ListSubItems.Add , , "" & rec("tindakan")
    'lvItem.ListSubItems.Add , , "" & rec("hari")

    'Isnull(rec("hari")) ialah test untuk tengo kalau nilai yang dibaca dpd field hari ialah null atau kosong
    ElseIf IsNull(rec("hari")) Then
    Set lvItem = lvJadual.ListItems.Add(, , "")
    lvItem.ListSubItems.Add , , "" & rec("peruntukan")
    lvItem.ListSubItems.Add , , "" & rec("aktiviti")
    lvItem.ListSubItems.Add , , "" & rec("sasaran")
    lvItem.ListSubItems.Add , , "" & rec("jenisinput")
    lvItem.ListSubItems.Add , , "" & rec("tindakan")
    'lvItem.ListSubItems.Add , , "" & rec("hari")
    Else
    newDate = DateAdd("d", rec("hari"), DTPicker1)
    Set lvItem = lvJadual.ListItems.Add(, , "" & Format(newDate, "dd/mm/yyyy"))
    lvItem.ListSubItems.Add , , "" & rec("peruntukan")
    lvItem.ListSubItems.Add , , "" & rec("aktiviti")
    lvItem.ListSubItems.Add , , "" & rec("sasaran")
    lvItem.ListSubItems.Add , , "" & rec("jenisinput")
    lvItem.ListSubItems.Add , , "" & rec("tindakan")
    'lvItem.ListSubItems.Add , , "" & rec("hari")
    rec("tarikh") = Format(newDate, "dd/mm/yyyy")
    rec.Update
    End If
    rec.MoveNext
    LoopAttached Images
    Attached Images Attached Images
    Attached Files Attached Files

Similar Threads

  1. query tuning
    By dhaya in forum Database
    Replies: 11
    Last Post: 08-25-2003, 06:24 PM
  2. Query by Today's date
    By Andy Burns in forum Database
    Replies: 1
    Last Post: 01-04-2002, 10:06 AM
  3. Query to find totals by date
    By Ken in forum Database
    Replies: 3
    Last Post: 04-06-2001, 10:31 PM
  4. Dynamic Update of DAO Using Model Database
    By Larry Rebich in forum vb.announcements
    Replies: 0
    Last Post: 08-26-2000, 01:56 PM
  5. Database questions.
    By Kofi Brown in forum Database
    Replies: 4
    Last Post: 05-09-2000, 10:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center