List box filter by date

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi.. I am having trouble even starting to develop this code..

What i would like to do is have 2 text box one start date the other end
date, and I would like them to filter a list box based on the start and end
date inputted into the two text boxes

thanks...
 
BigRed,
In the query behind the Listbox (use a query, not a table) use the following criteria
against your Date field.
(use your own object names)
Between Forms!YourFormName!StartDate And Forms!YourFormName!EndDate

Use the AfterUpdate event of both Start and End to Requery the Listbox, to keep them in
sycnh.
 
thnks for the code Al, but I have one minor problem.
The dates are formatted and viewable in the query but does not transfer to
the List on the form and i wopuld also like a command button to active these
changes on the list..
If you can help me a little more i would very much apprciate it
 
BigRed,
What i would like to do is have 2 text box one start date the other end
date, and I would like them to filter a list box based on the start and end
date inputted into the two text boxes

You asked for a list box that can be filtered by 2 text boxes (dates) on a form...
StartDate and End Date.
Therefore, the listbox MUST contain some Date field that your Start/End values to
operate on. That date field in the listbox don't have to "show" in the actual listbox
listing, but it must be in the query.

You wrote..
The dates are formatted and viewable in the query but does not transfer to
the List on the form
I don't understand what you mean by that... but...
If you're saying that there is ONE date field in the listbox query that you are trying
to filter on, then use the criteria I gave you. **You can filter a listbox query by the
date values on the form... and still not show it/them in the listing. That's what the
"Show" checkbox is for in the query.**
SomeDate
Between Forms!YourForm!StartDate AND Forms!YourForm!EndDate

If, you're saying that you have 2 dates in the query from your table... a StartDate and
EndDate, then each will need it's own criteria...
StartDate EndDate
= Forms!YourForm!StartDate <= Forms!YourForm!EndDate

Also, a minor point... please leave my and your comments on your replies so we can both
see the complete sequence of this thread.
Thanks,
--
hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions
 
OK so this is what it is..
1)Listbox_1
2)Combobox
3)Listbox_2

-Listbox_1 is a list that displays all fields names in my table
-Combobox is the prompted to display certain values, based on which field is
chosen
-After the value is chosen it then filters Listbox_2 to output which records
have the designated value in the designated field
-My problem is that I have check box fields in the firstlist box also with
many other fields that are text based..What I cant get to work is for
ListBox_2 to prompt record results. List_1 and The combo box bring up the
right value and field..
 
BIGRED56,
What happened to the date fields question?
What i would like to do is have 2 text box one start date the other end
date, and I would like them to filter a list box based on the start and end
date inputted into the two text boxes.

I think you're trying to re-invent the wheel here. From what I can understand, what
you want to do is already built into Access. It's called FilterByForm.
Right click on your form and select FilterByForm. You can select one or more fields on
the form*, set a criteria for one or more of those fields, and Access will locate the
records that satisfy that criteria/s.

*Each field will present you with a combo of legitimate values that have been entered
in your dataset records, from which you can select the value you wnat to filter on. This
sounds like just what your trying to do with your lists and combos... but you'll find the
FilterByForm much more flexible, and able to search many fields rather than just one.
 
Back
Top