Continuous filtering of a listbox

A

Alp Bekisoglu

Hi Experts,

Need to create a form (maybe with a sub-form) to do the following:
As the user types a company name the listbox below this textbox should
update and show matching records from the company table.

So far I have a query, a form based on this query and another form with an
unbound textbox as the input location. This form also has the query based
form as its sub. The query refers to the unbound textbox as its parameter.
SQL behind the query is:
SELECT co_main.co_id, co_main.co_adi
FROM co_main
WHERE (((co_main.co_adi) Like [Forms]![Form1]![Text0] & "*"));

Behind the mother form I have:
With Me.fr_qry_co_main_ara '.Properties
.Requery
.Visible = True
End With

I placed this code under BeforeUpdate, AfterUpdate, Change, and even
KeyPress but it does not do what I intend to do. It works as it is now if I
hit enter after each letter but that is not the goal.

I know this can be achieved but just couldn't find out how to.

Thanks in advance for any help or guidance.

Alp
 
M

MacDermott

You could try this in the textbox's Change event procedure:
Me.fr_qry_co_main_ara.RowSource="SELECT co_main.co_id, co_main.co_adi
FROM co_main WHERE (((co_main.co_adi) Like '" & [Forms]![Form1]![Text0].Text
& "*'));"

HTH
 
A

Alp Bekisoglu

Thanks for the suggestion but I'm getting "Method or Data Member not found"
error when I use it.

Alp

MacDermott said:
You could try this in the textbox's Change event procedure:
Me.fr_qry_co_main_ara.RowSource="SELECT co_main.co_id, co_main.co_adi
FROM co_main WHERE (((co_main.co_adi) Like '" &
[Forms]![Form1]![Text0].Text
& "*'));"

HTH



Alp Bekisoglu said:
Hi Experts,

Need to create a form (maybe with a sub-form) to do the following:
As the user types a company name the listbox below this textbox should
update and show matching records from the company table.

So far I have a query, a form based on this query and another form with
an
unbound textbox as the input location. This form also has the query based
form as its sub. The query refers to the unbound textbox as its
parameter.
SQL behind the query is:
SELECT co_main.co_id, co_main.co_adi
FROM co_main
WHERE (((co_main.co_adi) Like [Forms]![Form1]![Text0] & "*"));

Behind the mother form I have:
With Me.fr_qry_co_main_ara '.Properties
.Requery
.Visible = True
End With

I placed this code under BeforeUpdate, AfterUpdate, Change, and even
KeyPress but it does not do what I intend to do. It works as it is now if I
hit enter after each letter but that is not the goal.

I know this can be achieved but just couldn't find out how to.

Thanks in advance for any help or guidance.

Alp
 
M

MacDermott

fr_qry_co_main_ara is the name of your listbox, right?

Alp Bekisoglu said:
Thanks for the suggestion but I'm getting "Method or Data Member not found"
error when I use it.

Alp

MacDermott said:
You could try this in the textbox's Change event procedure:
Me.fr_qry_co_main_ara.RowSource="SELECT co_main.co_id, co_main.co_adi
FROM co_main WHERE (((co_main.co_adi) Like '" &
[Forms]![Form1]![Text0].Text
& "*'));"

HTH



Alp Bekisoglu said:
Hi Experts,

Need to create a form (maybe with a sub-form) to do the following:
As the user types a company name the listbox below this textbox should
update and show matching records from the company table.

So far I have a query, a form based on this query and another form with
an
unbound textbox as the input location. This form also has the query based
form as its sub. The query refers to the unbound textbox as its
parameter.
SQL behind the query is:
SELECT co_main.co_id, co_main.co_adi
FROM co_main
WHERE (((co_main.co_adi) Like [Forms]![Form1]![Text0] & "*"));

Behind the mother form I have:
With Me.fr_qry_co_main_ara '.Properties
.Requery
.Visible = True
End With

I placed this code under BeforeUpdate, AfterUpdate, Change, and even
KeyPress but it does not do what I intend to do. It works as it is now
if
I
hit enter after each letter but that is not the goal.

I know this can be achieved but just couldn't find out how to.

Thanks in advance for any help or guidance.

Alp
 
A

Alp Bekisoglu

No, sorry I did not mention which is which. fr_qry_co_main_ara is the name
of the subform based on the mentioned query.

Alp

MacDermott said:
fr_qry_co_main_ara is the name of your listbox, right?

Alp Bekisoglu said:
Thanks for the suggestion but I'm getting "Method or Data Member not found"
error when I use it.

Alp

MacDermott said:
You could try this in the textbox's Change event procedure:
Me.fr_qry_co_main_ara.RowSource="SELECT co_main.co_id,
co_main.co_adi
FROM co_main WHERE (((co_main.co_adi) Like '" &
[Forms]![Form1]![Text0].Text
& "*'));"

HTH



Hi Experts,

Need to create a form (maybe with a sub-form) to do the following:
As the user types a company name the listbox below this textbox should
update and show matching records from the company table.

So far I have a query, a form based on this query and another form
with
an
unbound textbox as the input location. This form also has the query based
form as its sub. The query refers to the unbound textbox as its
parameter.
SQL behind the query is:
SELECT co_main.co_id, co_main.co_adi
FROM co_main
WHERE (((co_main.co_adi) Like [Forms]![Form1]![Text0] & "*"));

Behind the mother form I have:
With Me.fr_qry_co_main_ara '.Properties
.Requery
.Visible = True
End With

I placed this code under BeforeUpdate, AfterUpdate, Change, and even
KeyPress but it does not do what I intend to do. It works as it is now if
I
hit enter after each letter but that is not the goal.

I know this can be achieved but just couldn't find out how to.

Thanks in advance for any help or guidance.

Alp
 
M

MacDermott

I don't think you even mentioned having a subform.
Of course it's the listbox whose RowSource property you'll be updating.
Use its name in the code I suggested.

Or perhaps you should just be using a combobox instead of a textbox and
listbox?

Alp Bekisoglu said:
No, sorry I did not mention which is which. fr_qry_co_main_ara is the name
of the subform based on the mentioned query.

Alp

MacDermott said:
fr_qry_co_main_ara is the name of your listbox, right?

Alp Bekisoglu said:
Thanks for the suggestion but I'm getting "Method or Data Member not found"
error when I use it.

Alp

You could try this in the textbox's Change event procedure:
Me.fr_qry_co_main_ara.RowSource="SELECT co_main.co_id,
co_main.co_adi
FROM co_main WHERE (((co_main.co_adi) Like '" &
[Forms]![Form1]![Text0].Text
& "*'));"

HTH



Hi Experts,

Need to create a form (maybe with a sub-form) to do the following:
As the user types a company name the listbox below this textbox should
update and show matching records from the company table.

So far I have a query, a form based on this query and another form
with
an
unbound textbox as the input location. This form also has the query based
form as its sub. The query refers to the unbound textbox as its
parameter.
SQL behind the query is:
SELECT co_main.co_id, co_main.co_adi
FROM co_main
WHERE (((co_main.co_adi) Like [Forms]![Form1]![Text0] & "*"));

Behind the mother form I have:
With Me.fr_qry_co_main_ara '.Properties
.Requery
.Visible = True
End With

I placed this code under BeforeUpdate, AfterUpdate, Change, and even
KeyPress but it does not do what I intend to do. It works as it is
now
if
I
hit enter after each letter but that is not the goal.

I know this can be achieved but just couldn't find out how to.

Thanks in advance for any help or guidance.

Alp
 

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