set unbound listbox recordset to sorted and filtered ADO recordset

T

Toxalot

I'm using Access 2003. I have a split database. I'm using ADO to
access the BE.

I have an unbound form with an unbound listbox. On the form's open
event I am retrieving an ADO recordset. This recordset has 965
records. If I set the listbox recordset to the ADO recordset then
everything works as expected (ie listbox has 965 records). But if I
sort and filter the ADO recordset first, then the listbox only ever
has 100 records. If I remove the sort, then the listbox has 138
records (same as the recordset).

'code snippets
'the following results in 100 records in the listbox
rsCities.Sort = "txtCityName"
rsCities.Filter = "txtProvinceCode = 'NS'"
Set Me.lstCities.Recordset = rsCities

'the following results in 138 records in the listbox
rsCities.Filter = "txtProvinceCode = 'NS'"
Set Me.lstCities.Recordset = rsCities

'the following results in 138 records in the listbox
rsCities.Sort = "txtCityName"
rsCities.Filter = "txtProvinceCode = 'NS'"
Do Until rsCities.EOF
Me.lstCities.AddItem rsCities!txtProvinceCode & ";" & rsCities!
txtCityName
rsCities.MoveNext
Loop

The last snippet shows that the recordset does indeed have 138
records, but looping through them is much slower then setting the
listbox's recordset. I don't want to use SQL for the sort and filter
because the form has buttons that allow the user to change the sort
and filter and I don't want to hit the database every time.

What's going on here?

Jennifer
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top