trystanhuwwilliams
Programmer
Hello,
This is my code:
Dim DAO As Database
Dim RS As DAO.Recordset
Set DB = CurrentDb
Set RS = DB.OpenRecordset("SELECT * FROM MAIL WHERE_ _NAME= '" & NAME & "' and XOPEN<>-1;", dbOpenDynaset)
With RS
.Movefirst
.Movelast
End With
TOT=RS.Recordcount:msgbox tot
DoCmd.OpenForm 'MAILB', , , , acFormEdit
This code opens a form based on a query which displays only the records filtered by the SQL statement. i.e NAME(text) & XOPEN (Yes/No box).
What I want to know is why does the Recordcount only count the records filtered by the first part of the statement & ignores the second. The form itself works fine & will only display records matching the Name & where 'XOPEN' = 'No', while the Recordcount will count all the records matching the name whether 'XOPEN' = 'Yes' or 'No'
Does anyone knows why this happens?
Cheers,
T
This is my code:
Dim DAO As Database
Dim RS As DAO.Recordset
Set DB = CurrentDb
Set RS = DB.OpenRecordset("SELECT * FROM MAIL WHERE_ _NAME= '" & NAME & "' and XOPEN<>-1;", dbOpenDynaset)
With RS
.Movefirst
.Movelast
End With
TOT=RS.Recordcount:msgbox tot
DoCmd.OpenForm 'MAILB', , , , acFormEdit
This code opens a form based on a query which displays only the records filtered by the SQL statement. i.e NAME(text) & XOPEN (Yes/No box).
What I want to know is why does the Recordcount only count the records filtered by the first part of the statement & ignores the second. The form itself works fine & will only display records matching the Name & where 'XOPEN' = 'No', while the Recordcount will count all the records matching the name whether 'XOPEN' = 'Yes' or 'No'
Does anyone knows why this happens?
Cheers,
T