Re: Combo box filtering

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Method A: Always show only the current students in this form
=======
1. Create a query using this table.

2. I the Criteria under this field, enter:
"Current"

3. Save the query.

4. Use the query as the RecordSource for your form.

Method B: Always open the form with a Filter, so the user can remove it.
=======
1. Open the form in design view.

2. Open the Properties box so it shows the properties of the form.

3. On the Events tab, set the On Click property to:
[Event procedure]

4. Click the Build button (...) beside this.
Access opens the code window.

5. Set up the event procedure so it looks like this:
Private Sub Command99_Click()
Me.Filter = "[Status] = 'current'"
Me.FilterOn = True
End Sub

(Use the name of your command button instead of Command99.)

Method C: Open the form from a button, so it only shows current students
=======
In the Click event procedure of the command button, use the WhereCondition
of OpenForm, e.g.:
DoCmd.OpenForm "MyForm", WhereCondition:="[Status] = 'current'"
where MyForm represents the name of the form, and Status the name of the
field.

Note:
===
If this Status field is a Number field, use the number without quotes in
each case, e.g.:
"[Status] = 2"

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"charleedongo" <charleedongo@xxxxxxxxxxx> wrote in message
news:1149439858.566927.194680@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Thank You allen.
Your code worked. I have one more favor to ask you. One of the combo
boxes has values "Current", "vacation""Discontinued". I would like my
form to open to show only the current students. So when i open the
continuous form, it should give me a filtered result of the current
students only.
Please help.
Allen Browne wrote:
Okay. You can ignore the examples for numbers, and dates, and just use
the
code that has all those quotes for each of your cases.

"charleedongo" <charleedongo@xxxxxxxxxxx> wrote in message
news:1149091406.619476.305650@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Thanks Allen,
I downloaded the sample. All my data type is Text.
The user has limited choice in each of the combo boxes to pick from.
It is for a School. In the first combo box, the values are Math,
Reading , or Math and reading.
The second combo box value is the classroom they are assigned to, which
is limited. Junoir, Middle and Higher.
The third combo box, the most important one, is the status of each
student. They are current, Vacation, Discontinued.
I looked at your sample and that is exactly what i wanted, but with no
date filters or number filters.
If you need more info of my table structure, let me know.
Thanks for your time
Allen Browne wrote:
So you want to place 3 unbound combo boxes in the Form Header, and a
command
button to apply the filter based on whatever combination of values the
user
entered?

You will need to use VBA code to create the string to use for the
Filter
of
the form. The actual details will depend on the data type of these
fields.

If you can use VBA, and would like an exmaple to follow, download:
http://allenbrowne.com/unlinked/Search2000.zip
The small sample database shows how to build the Filter string from
the
boxes that have values, and how to use the delimters for the different
data
types. Requires Access 2000 or later.


"charleedongo" <charleedongo@xxxxxxxxxxx> wrote in message
news:1149015121.793434.183700@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hello Everyone,
Iam facing a problem when i try to filter a continuous form with
multiple combo boxes.
here is the situation. The form is based on a query. The query has
fields,
Last name
First Name
Subject
Status
Classroom

Subjects offered are Math and reading. Status is current, vacation,
discontinued.
Classroom is Junoir, Middle, Higher.
I would like to create such a filter where iam able to see all the
math
students alone or reading students alone. These are dependent on the
status field. For example, i would like to see all math students who
are current in the Junior class room. I understand that this
requires
three combo boxes which are interconnected.
Pls help me with the code by which i can achieve this.


.



Relevant Pages

  • RE: Open form unfiltered if strWhere is blank
    ... So thanks for the heads up to check 'one more time' that the filter property ... Is the record source for the form a query or a table? ... are still used and the form opens filtered. ...
    (microsoft.public.access.formscoding)
  • RE: Open form unfiltered if strWhere is blank
    ... "Type" is a reserved word in Access and shouldn't be used to name objects in ... Is the record source for the form a query or a table? ... Another thing to check - open the form in design view and check the filter ... are still used and the form opens filtered. ...
    (microsoft.public.access.formscoding)
  • Re: Open Query to Filter by Form
    ... I mean the 'Filter by Form' command which is available on the query toolbar - ... I have a combo box on a form which opens as a dialog box. ... that my db user can pick the appropriate name from the dropdown in the query ...
    (microsoft.public.access.queries)
  • Re: Form filter on date
    ... When the user opens the form it should only show data for the this year ... You can use a query as the form's record source. ... It is way more efficient to filter the data users need to ... users can enter the filtering criteria and after the ...
    (microsoft.public.access.formscoding)
  • Re: date useage in vb expression
    ... small unbound form to hold the unbound date controls. ... *remove the criteria in the query.* instead, ... When I open the query it opens a dialog box ... >> query or filter to reference those two controls. ...
    (microsoft.public.access.formscoding)