Hi
Difficult to say what the problem is without seeing your query string construction.
I assume there are records between the dates selected ?
For information this code works find
Code:
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim SQL As String
Dim StartDate As String
Dim EndDate As String
StartDate = "31/12/06"
EndDate = "31/01/07"
cn.Open "TEST"
SQL = "Select Count(DWN) as DwkCount from tblDayworks "
SQL = SQL & "WHERE StartDate BETWEEN #" & Format(StartDate, "mm/dd/yy") & "# AND #" & Format(EndDate, "mm/dd/yy") & "#"
rs.Open SQL, cn, adOpenStatic, adLockReadOnly
MsgBox rs(0)
This also gives the same result (count)
Code:
SQL = "Select DWN from tblDayworks "
SQL = SQL & "WHERE StartDate BETWEEN #" & Format(StartDate, "mm/dd/yy") & "# AND #" & Format(EndDate, "mm/dd/yy") & "#"
rs.Open SQL, cn, adOpenStatic, adLockReadOnly
MsgBox rs.RecordCount
You do not say what your computer regional date format is (I'm in the UK).
One thought is that your date field name is 'date' (not a good idea, as I have found out) so try this
sSQL = "Select count(PrimaryKeyFieldName) as valcount from price " & _
"WHERE [date] between #" & format(startdate,"mm/dd/yy") & "# and #" & fromat(enddate,"mm/dd/yy") & "#"
ie put [] round date
I am also not sure what you have dimensioned as integer !?
MTB