Multi-Select LIstbox can it be searched easily?

Actually it's not strange for it to show a count after all the records have appeared because it is counting line by line.

If you want an instantaneous count then perform a RecordCount on the RecordsetClone of the form and set the returned count to the VALUE of the textbox, not control source. You will apply this on your Filter and Reset Filter command buttons right after Me.FilterOn. Research those methods.

Cool, I did this:
dim record_count as Long
Me.Filter = strWhere
Me.FilterOn = True
record_count = Me.RecordsetClone.RecordCount
Me.txtSearchResults.Value = record_count

and it worked! Thanks again you are very clever!!
 
Excellent. It's better you do this:
Code:
    Dim rst As DAO.Recordset
    Set rst = Me.RecordsetClone

    If rst.RecordCount <> 0 Then
        rst.MoveLast
        rst.MoveFirst
    End If
    txtSearchResults.Value = rst.RecordCount
 
Cool, I did this:
dim record_count as Long
Me.Filter = strWhere
Me.FilterOn = True
record_count = Me.RecordsetClone.RecordCount
Me.txtSearchResults.Value = record_count

and it worked! Thanks again you are very clever!!


And this works too!
Code:
Me.txtSearchResults.Value = "Your search returned " & record_count & " supplier(s)."
:D
 
Excellent. It's better you do this:
Code:
    Dim rst As DAO.Recordset
    Set rst = Me.RecordsetClone
 
    If rst.RecordCount <> 0 Then
        rst.MoveLast
        rst.MoveFirst
    End If
    txtSearchResults.Value = rst.RecordCount

Oo that looks nice what does the movelast/first mean?? Can I still put the text into the last expression to make a sentence??
 
Oo that looks nice what does the movelast/first mean?? Can I still put the text into the last expression to make a sentence??

THis seems to work ok; would it be frowned upon to use it this way?
txtSearchResults.Value = "Your search returned " & rst.RecordCount & " supplier(s)."
 
To get an accurate record count of a recordset you need to move last to populate the recordset, then perform your count. You don't actually need the move first so you can take it off. If you don't populate your recordset then you will notice that it's only counting the visible records.

Yes you still can.
 
To get an accurate record count of a recordset you need to move last to populate the recordset, then perform your count. You don't actually need the move first so you can take it off. If you don't populate your recordset then you will notice that it's only counting the visible records.

Yes you still can.

Cool! Thanks again!:D
 
You're welcome. Have a look in the help files for more concise explanations of movelast, movefirst, EOF and BOF of a recordset.

Good luck!
 

Users who are viewing this thread

Back
Top Bottom