Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2005
    Posts
    61

    Lightbulb Unanswered: Urgent :::NEEED HELP IN VB6 And SQL Statment

    HI All
    I really Need Help In The Following

    i have Connect to Access Database By Sql Statment
    And i want to Make A Select Statment like This

    Select * From Tabel1 where Date Between #31/12/2004# And #31/12/2004#
    but I want To put FD and TD Instead of 31/12/2004
    how to make this i tried more than One Way And Nothing Work

    here is my Code

    On Error Resume Next
    DataGrid1.Refresh
    rs.Close
    DataGrid1.Refresh
    Dim FD
    Dim TD

    FD = Text7.Text
    TD = Text8.Text

    rs.CursorLocation = adUseClient

    ------ This Worked --------
    rs.Open "SELECT CarSales.CSeq, CarSales.Make, CarSales.Model, CarSales.Year, CarSales.Qty, CarSales.Cat, CarSales.CnOrg, CarSales.Date From CarSales WHERE (((CarSales.Date) Between #12/31/2004# And #12/31/2004#));"
    -------This Does NOT WOrk WHY ????!!!!!!!!!!
    'rs.Open "SELECT CarSales.CSeq, CarSales.Make, CarSales.Model, CarSales.Year, CarSales.Qty, CarSales.Cat, CarSales.CnOrg, CarSales.Date From CarSales WHERE (((CarSales.Date) Between #" & FD & "# AND #" & TD & "#", db

    Set DataGrid1.DataSource = rs

    If rs.RecordCount < 1 Then
    MsgBox " THERE IS NO RECORDS "
    Label3.Caption = 0
    Text7.SetFocus
    Else
    Label3.Caption = rs.RecordCount
    End If


    Please I need YOUR HELP
    Sami Al Damiri ...

  2. #2
    Join Date
    Feb 2006
    Posts
    3
    hi,

    try this

    dim FD as Date
    dim TD as Date

    FD = cdate(text1.text)
    TD = cdate(text2.text)

    rs.Open "SELECT CarSales.CSeq, CarSales.Make, CarSales.Model, CarSales.Year, CarSales.Qty, CarSales.Cat, CarSales.CnOrg, CarSales.Date From CarSales WHERE (((CarSales.Date) Between #" & FD & "# AND #" & TD & "#", db

    or you can use dtpicker control rather than textbox in displaying your date.


    happy coding!

    best regards,

    saldiboy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •