Filter Listbox

A

Asif

I have a listbox that contains two columns Date and Quantity above the
listbox I have a two text boxes one showing the current month and one
showing the current year. I also have two command buttons for each
textbox i.e. to increase/decrease the month or year field. In the
query for this listbox I've set the criteria for the date field to
"Month([Date])=Month(Now())" and when I run the query all records for
the current month are displayed.

Now what I want to do is when I click on the command button to set the
month back to March I want the records to filter so that only the
entires for March are displayed likewise if i increase the month only
records for May are displayed (Similar procedure for year field as
well)

Any ideas???

Thanks
 
J

Jeff Boyce

So, you are saying that you want the listbox to refresh itself after you
click one of those buttons that change date information?

Add code to the button that tells the listbox to requery itself, something
like:
lstYourListBox.Requery

Change the listbox's query to use a selection criterion that points to the
textbox on your form. For example, under the Month([YourDateField]), put
something like Month(Forms!frmYourForm!txtYourDateTextControl (use your
field, form and control names).

By the way, if your table actually has a field named [Date], reconsider ...
Access treats this as a reserved word.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 

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