Solved List box help (1 Viewer)

tfaisal

New member
Local time
Tomorrow, 01:03
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
 

Ranman256

Well-known member
Local time
Today, 16:03
Joined
Apr 9, 2015
Messages
4,337
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
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 16:03
Joined
May 21, 2018
Messages
8,555

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.
 

tfaisal

New member
Local time
Tomorrow, 01:03
Joined
Mar 8, 2020
Messages
8
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
 

tfaisal

New member
Local time
Tomorrow, 01:03
Joined
Mar 8, 2020
Messages
8
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
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 16:03
Joined
May 21, 2018
Messages
8,555
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:

tfaisal

New member
Local time
Tomorrow, 01:03
Joined
Mar 8, 2020
Messages
8

Attachments

  • DatabaseProject (1) - Copy.accdb
    780 KB · Views: 224

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 04:03
Joined
May 7, 2009
Messages
19,247
check and test
 

Attachments

  • DatabaseProject (1) - Copy.accdb
    804 KB · Views: 291

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 04:03
Joined
May 7, 2009
Messages
19,247
see changes on the code.
 

Attachments

  • DatabaseProject (1) - Copy (1).accdb
    776 KB · Views: 292

Users who are viewing this thread

Top Bottom