Author Topic: To filter data by date  (Read 847 times)

Padex

  • Newbie
  • *
  • Posts: 11
    • View Profile
To filter data by date
« on: February 10, 2017, 03:59:01 AM »
Hi All,

Need your help... Im trying to filter my data based on SQLString but is not done well... catch all data... below is the code

Code: [Select]
Private Sub Show_Filter()
        Dim SQLString As String
        Dim Date1 As String
        Dim Date2 As String



        Date1 = DateFrom.Date & " 12:00:00 AM"
        Date2 = DateTo.Date & " 11:59:59 PM"


        TableName = "CAcpm"

        SQLString = "SELECT CAcpm.[No], CAcpm.Time, CAcpm.Date, CAcpm.[Pre CA], CAcpm.[Pos CA], CAcpm.[CA volume], CAcpm.Result, CAcpm.SKU, CAcpm.Remark, CAcpm.UserRec, CAcpm.[Vision Status], CAcpm.Station, CAcpm.UserIssue FROM " & TableName & " WHERE DateIn BETWEEN #" & Date1 & "# AND #" & Date2 & "#"


        ds.Clear()
        rs.CursorLocation = ADODB.CursorLocationEnum.adUseClient
        rs.Open(SQLString, conn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic)

        da.Fill(ds, rs, TableName)

        DataGridView1.DataSource = ds.Tables(0)

    End Sub

Mikefly95

  • Jr. Member
  • **
  • Posts: 80
    • View Profile
Re: To filter data by date
« Reply #1 on: February 10, 2017, 08:14:00 AM »
What Data base are you using?

bachphi

  • Hero Member
  • *****
  • Posts: 643
    • View Profile
Re: To filter data by date
« Reply #2 on: February 11, 2017, 10:24:19 AM »
I would set breakpoint at the date, step through and look at the  result of the dates, and sqlstring and see if its correct
« Last Edit: February 11, 2017, 10:28:51 AM by bachphi »
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================