Solved List box help

tfaisal

New member
Local time
Tomorrow, 01:11
Joined
Mar 8, 2020
Messages
8
Hello
I want to filter list box without text or combo box
e.g when i type S the grantee goes to first s record but if i type one more letter like SAM then it search on first letter instead of going to last record which has grantee SAM .How can i do that
1628172373894.png
 
above the listbox add a text box.
as you type the letters, have it filter the listbox.
you use 2 queries:
1 qsList shows all records,
2: qsListFilter looks at the txtbox to filter on whats in it:
select * from table where [grantee] like forms!fMyForm!txtFind & "*"


Code:
Private Sub txtFind_Change()
FilterList
End Sub


sub FilterList
if IsNull(txtFind) then
lstBox.rowsource = "qsList"
else
lstBox.rowsource = "qsListFilter"
endif
lstBox.requery
end sub
 

However IMO this is a worthless setup. It is more confusing than useful. Using a textbox is way more user friendly and flexible. You can type in "ALI" which finds nothing. Then back up to AL and type ALE. Without the textbox you have no way to clear the filter or backup. Eventually you do not remember what is typed.
 
However IMO this is a worthless setup. It is more confusing than useful. Using a textbox is way more user friendly and flexible. You can type in "ALI" which finds nothing. Then back up to AL and type ALE. Without the textbox you have no way to clear the filter or backup. Eventually you do not remember what is typed.
Thankyou for your reply.Form on attached file types in textbox i dont want a textbox want to do directly
 
above the listbox add a text box.
as you type the letters, have it filter the listbox.
you use 2 queries:
1 qsList shows all records,
2: qsListFilter looks at the txtbox to filter on whats in it:
select * from table where [grantee] like forms!fMyForm!txtFind & "*"


Code:
Private Sub txtFind_Change()
FilterList
End Sub


sub FilterList
if IsNull(txtFind) then
lstBox.rowsource = "qsList"
else
lstBox.rowsource = "qsListFilter"
endif
lstBox.requery
end sub
Thankyou for your reply i dont want a textbox want to do directly on listbox
 
My demo show how to do it without a textbox. I provided the textbox for demo purposes only to show you the results. Read the thread.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom