DanSeal100
asked on
Keeping a list box blank until something is typed into the control the query is based on
Hi,
I have a list box based on a query. I would like the list to appear blank/empty when the form first opens and stay this way until the user types something into one of the controls that the query running the list box is based on.
What is the best way of doing this?
I have a list box based on a query. I would like the list to appear blank/empty when the form first opens and stay this way until the user types something into one of the controls that the query running the list box is based on.
What is the best way of doing this?
use the change event of the control...
what is the Rowsource of the Listbox?
private sub textBox_change()
dim str as string, sql
str=str & me.textbox.text
sql="select f1,f2 from tableName where f2 like '" & str & "*'"
me.listbox.rowsource=str
end sub
what is the Rowsource of the Listbox?
private sub textBox_change()
dim str as string, sql
str=str & me.textbox.text
sql="select f1,f2 from tableName where f2 like '" & str & "*'"
me.listbox.rowsource=str
end sub
ASKER
Thanks for your advice, I actually have the control updating the list box on the change event. It re queries the list box to do this.
The only problem is what happens before the user types anything into any of the controls. At the moment before they type anything all the records in the database are shown in the list box and this is a bit confusing to the user. I wondered if there was a way to get the list box to show nothing until the user types something.
The only problem is what happens before the user types anything into any of the controls. At the moment before they type anything all the records in the database are shown in the list box and this is a bit confusing to the user. I wondered if there was a way to get the list box to show nothing until the user types something.
remove the row source of the list box from the Property sheet and assign the rowsource in the change event of the textbox
private sub textBox_change()
dim str as string, sql
str=str & me.textbox.text
sql="select f1,f2 from tableName where f2 like '" & str & "*'"
me.listbox.rowsource=str
end sub
private sub textBox_change()
dim str as string, sql
str=str & me.textbox.text
sql="select f1,f2 from tableName where f2 like '" & str & "*'"
me.listbox.rowsource=str
end sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Private Sub Text1_AfterUpdate()
Me.YourListBoxName.RowSour
End Sub
Add same code for the other controls the list box is based on.
mx