I have a select statement that I am trying to open but it never makes it past the recordset open command. Here is the function that is causing me grief.
Public Function DeptTimes()
Dim rst As ADODB.Recordset
Dim cnn As ADODB.Connection
Set rst = New ADODB.Recordset
Dim strSQL As String
Dim dteInDate As Date
Dim dteOutDate As Date
strSQL = "SELECT * FROM [qryTrackingData_EndTimes]"
strSQL = strSQL & "WHERE [UserID] = '" & Me.UserID & "'"
strSQL = strSQL & " AND [SystemDate] >= " & "#" & Me.Indate & "#"
strSQL = strSQL & " ORDER BY qryTrackingData_EndTimes.SystemDate"
rst.Open strSQL, cnn, , , adOpenStatic 'Problem here
rst.MoveLast
If rst.RecordCount < 2 Then
DeptTimes = 0
Else
rst.MoveFirst
dteInDate = rst![SystemDate]
rst.MoveNext
dteOutDate = rst![SystemDate]
DeptTimes = rst![SystemDate]
End If
Set rst = Nothing
End Function
If anyone can give me a clue what I am doing wrong I would greatly appreciate it.
Public Function DeptTimes()
Dim rst As ADODB.Recordset
Dim cnn As ADODB.Connection
Set rst = New ADODB.Recordset
Dim strSQL As String
Dim dteInDate As Date
Dim dteOutDate As Date
strSQL = "SELECT * FROM [qryTrackingData_EndTimes]"
strSQL = strSQL & "WHERE [UserID] = '" & Me.UserID & "'"
strSQL = strSQL & " AND [SystemDate] >= " & "#" & Me.Indate & "#"
strSQL = strSQL & " ORDER BY qryTrackingData_EndTimes.SystemDate"
rst.Open strSQL, cnn, , , adOpenStatic 'Problem here
rst.MoveLast
If rst.RecordCount < 2 Then
DeptTimes = 0
Else
rst.MoveFirst
dteInDate = rst![SystemDate]
rst.MoveNext
dteOutDate = rst![SystemDate]
DeptTimes = rst![SystemDate]
End If
Set rst = Nothing
End Function
If anyone can give me a clue what I am doing wrong I would greatly appreciate it.