none
Expert Opinion: rs.MoveFirst shows error (this is because it does not show any data) although SQL looks fine. What is the reason behind this? RRS feed

  • Question

  • sqlString = "SELECT [ActivityLog].* " & _
                "from [ActivityLog] " & _
                "where Format([ActivityLog].[ETime],""yyyy/mm/dd"") between " & [Forms]![DashBoardF]![CmbBeginTime] & " and " & [Forms]![DashBoardF]![CmbEndTime] & ";"

    Set rs = CurrentDb.OpenRecordset(sqlString)


    Stop
    If rs.RecordCount > 0 Then
    MsgBox ("UserName Found")
    Else
    MsgBox ("UserName Not Found")
    'DoCmd.Close
    End If

    '' where as  rs.RecordCount it shows 0. That is why next syntax give me error. 
    rs.MoveFirst

    Can you tell me, where is the problem in sqlString? 

    Thanks in advance.


    • Edited by Rasel Biswas Thursday, January 31, 2019 6:52 PM clarification
    Thursday, January 31, 2019 6:52 PM

All replies

  • Check this:

    WHERE DateValue([ActivityLog].[ETime]) BETWEEN CDate(" & [Forms]![DashBoardF]![CmbBeginTime] & ") AND CDate(" & [Forms]![DashBoardF]![CmbEndTime] & ");"

    Thursday, January 31, 2019 7:34 PM