Update a listbox after a filter by selection

G

Guest

hopefully there is a simple solution for this one ...

I have a form which contains a series of textboxes and a list box which is
referenced a table, (eg Table2). The purpose of the textboxes is to list
individual fields of a single record, and the listbox (which resides in the
footer) is used to display all of the records.

Here is where I am having a problem...
when I select one of the text boxes and do a filter by selection, it of
course filters the records, and using the navigation buttons at the bottom of
the form, I can see the information that the record contains. Great! The
problem is that I want the listbox to show the rest of the filtered records
in a tabular form, however presently it shows all records. Is there a simple
way to accomplish this without having to write a query for each field? I'm
new to database authoring, so I'm assuming that I'm missing something basic
here. Thanks for any advice anyone can offer!
 
G

Guest

Hi godadj,

Set the rowsource of your listbox based on your form's filter and refresh
it...

Put the following code in the "On Apply Filter" event of your form:
If Me.FilterOn Then
Me.LISTBOX.RowSource = "<SELECT STATEMENT> WHERE " & Me.Filter

Else
Me.LISTBOX.RowSource = "<SELECT STATEMENT>"

End If
Me.LISTBOX.Requery


Obviously you need to replace <SELECT STATEMENT> with the SQL statement you
are using, and LISTBOX with the name of your listbox.

Hope this helps.

Damian.
 
G

Guest

Thanks Damian, it worked perfectly, and was a simple enough fix! I dreaded
the idea of having to rewrite the entire thing for such a simple requirement.
Again thank you for your help!
 

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