DataCombo And Filtered Recordsets - TechRepublic
General discussion
May 16, 2003 at 02:20 AM
setivi

DataCombo And Filtered Recordsets

by setivi . Updated 22 years, 10 months ago

(Assume all the necessary and proper variables have been declared.)
‘Filter ADO recordset
ADOEmpFile.Recordset.Filter =”Lname = ‘Smith'”
‘Count filtered records
LongRecs = ADOEmpFile.Recordset.RecordCount
‘The value of LongRecs = 100 in Debug.Print
‘indicated that the filter worked.

‘Now, populate DataCombo1 with filtered
‘recordsets
With DataCombo1
Set .RowSource = ADOEmpFile.Recordset
.ListField = “Lname”
End With
After the execution of the With segment above, the DataCombo1 should have only 100 records in its listfield, I think, but it has 5000 records, a list of all the last names in the entire Employee file. What am I doing wrong? I only want all last names with Smith to befiltered into the DataCombo1. Please Help!

This discussion is locked

All Comments