CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: From date & to date is not Searching properly In MSHFlexgrid1

  1. #1
    Join Date
    May 2020
    Posts
    1

    From date & to date is not Searching properly In MSHFlexgrid1

    The problem is when I search for the data i.e people{Shubhankar Haldar} within specific date {[1/5/2020] & [18/5/2020]} as in attached picture, the output date which comes is not within specified date.Also some of the dates that falls under the the specified date are missing.

    Code:
    Private Sub search2_Click()
    Set rs_pay = New ADODB.Recordset
    Set adv_pay = New ADODB.Recordset
    rs_pay.Open "Select sum(advalue) from (select ename,date1,advalue from advanceentry where date1>= # " & Format$(Me.DTPicker1.Value, "dd/MM/yyyy") & " # and date1<= # " & Format$(Me.DTPicker2.Value, "dd/MM/yyyy") & " # and ename='" & L_ename.Text & "')", cd_pay, adOpenStatic, adLockOptimistic
    
    
    adv_pay.Open " select ename,date1,advalue,date2 from advanceentry where date1>= # " & Format$(Me.DTPicker1.Value, "dd/mm/yyyy") & " # and date1<= # " & Format$(Me.DTPicker2.Value, "dd/mm/yyyy") & " # and ename='" & L_ename.Text & "' order by date2", cd_pay, adOpenStatic, adLockOptimistic
    If adv_pay.EOF Then
        MsgBox ("NO RCORDS FOUND FOR SELECTED DATE!")
        Else
    Set MSHFlexGrid2.DataSource = adv_pay
    If IsNull(rs_pay(0)) Then
        T_prday.Text = ""
        Else
        T_prday.Text = rs_pay(0)
        
        Me.cmd_print.Enabled = True
        End If
        End If
    End Sub

  2. #2
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,345

    Re: From date &amp; to date is not Searching properly In MSHFlexgrid1

    Well first of all this has nothing to do with flexgrid. Whatever issue you have is with your query or your data.

    Access expects mm/dd/yyyy for date formats you are trying to use dd/mm/yyyy which is likely the source of your issue.
    http://allenbrowne.com/ser-36.html
    Last edited by DataMiser; May 23rd, 2020 at 08:13 AM.
    Always use [code][/code] tags when posting code.

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)