A
Art
Hello,
I am writing a function to return a recordset
length.
Public Function RecordsetLength(StartDate As Date,
EndDate As Date) As Variant
Dim CurrDB As New ADODB.Connection
Dim abc As New ADODB.Recordset
Dim strSQL As String
Set CurrDB = CurrentProject.Connection
strSQL = "SELECT ALL CallLog.Topic, CallLog.[Call
Status],CallLog.[Internal / External] FROM CallLog WHERE
(" & _
"[Opened Date]>#" & StartDate & _
"# And [Opened Date]<#" & EndDate _
& "#) and Left([Topic],3)= ""ECR"";"
abc.CursorType = adOpenKeyset
abc.LockType = adLockOptimistic
abc.Open strSQL, CurrDB, , , adOpenKeyset
abc.MoveFirst
abc.MoveLast
RecordsetLength = abc.RecordCount
End Function
This works but it does not return the correct amount of
records.It returns 150
I have a query on the same table as my function.It has the
following constraints:
LIKE "ECR*"
BETWEEN startdate AND enddate
This query returns 168.
I have tried to change the code to use the LIKE clause.
When I do so, however, it returns an empty recordset.
strSQL = "SELECT ALL CallLog.Topic, CallLog.
[Call Status],CallLog.[Internal / External] FROM CallLog
WHERE (" & _
"[Opened Date]>#" & StartDate & _
"# And [Opened Date]<#" & EndDate _
& "#) and [Topic] Like ""ECR*"";"
I am probably messing something up. If someone can spot
where I went off the rails, they could make my weekend.
Thank you in advance for any efforts to help out.
Art
I am writing a function to return a recordset
length.
Public Function RecordsetLength(StartDate As Date,
EndDate As Date) As Variant
Dim CurrDB As New ADODB.Connection
Dim abc As New ADODB.Recordset
Dim strSQL As String
Set CurrDB = CurrentProject.Connection
strSQL = "SELECT ALL CallLog.Topic, CallLog.[Call
Status],CallLog.[Internal / External] FROM CallLog WHERE
(" & _
"[Opened Date]>#" & StartDate & _
"# And [Opened Date]<#" & EndDate _
& "#) and Left([Topic],3)= ""ECR"";"
abc.CursorType = adOpenKeyset
abc.LockType = adLockOptimistic
abc.Open strSQL, CurrDB, , , adOpenKeyset
abc.MoveFirst
abc.MoveLast
RecordsetLength = abc.RecordCount
End Function
This works but it does not return the correct amount of
records.It returns 150
I have a query on the same table as my function.It has the
following constraints:
LIKE "ECR*"
BETWEEN startdate AND enddate
This query returns 168.
I have tried to change the code to use the LIKE clause.
When I do so, however, it returns an empty recordset.
strSQL = "SELECT ALL CallLog.Topic, CallLog.
[Call Status],CallLog.[Internal / External] FROM CallLog
WHERE (" & _
"[Opened Date]>#" & StartDate & _
"# And [Opened Date]<#" & EndDate _
& "#) and [Topic] Like ""ECR*"";"
I am probably messing something up. If someone can spot
where I went off the rails, they could make my weekend.
Thank you in advance for any efforts to help out.
Art