Filtering a Form

  • Thread starter Thread starter Bryan Brassell
  • Start date Start date
B

Bryan Brassell

I have a form which pulls from a single table. One of the
fields is "Branch". Upon opening the form, I would like
the user to have to selet from a list of branches (there
is another table with this information). Based on the
user selection (combobox), I want the form to open and be
filtered (filtered by the selection).

Any ideas on the best approach? I tried a separate "pop-
up" form, but it is behaving like a transactional form.

Regards,

Bryan Brassell
 
There is a combo box wizard that will set this up for you. Essentially you
put a combo box in the form's Header and use it to filter the form's
recordsource.

While your form is open in design view, click on the wizard icon on the
toolbox. Then click on the combo box control and then click on the form. The
wizard will open; choose the option that says I want to find a record on my
form based on the value I select in my combo box. It'll take you the rest of
the way.
 
Works like a charm, thanks! I tried the wizard, but must
have set something wrong, so I did it from scratch with
the code which now works.

thanks...


-----Original Message-----
Bryan,

Add a combo box to the Form Header.
Set it's rowsource to a SQL that returns the Branch ID and/or the Branch
Name fields. As an example:

SELECT DISTINCT YourTable.Branch FROM YourTable ORDER BY YourTable.Branch;

If [Branch] is a Text datatype,
Code the Click event of the Combo Box:

Me.Filter = "Branch = '" & [ComboName] & "'"
Me.FilterOn = True

If [Branch] is a Number datatype:
Me.Filter = "Branch = " & [ComboName]
Me.FilterOn = True

Set the combo Auto Expand property to Yes.
Set the Limit To List property to Yes.

Find the branch in the combo box and the form will filter the records for
that branch.

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.


Bryan Brassell said:
I have a form which pulls from a single table. One of the
fields is "Branch". Upon opening the form, I would like
the user to have to selet from a list of branches (there
is another table with this information). Based on the
user selection (combobox), I want the form to open and be
filtered (filtered by the selection).

Any ideas on the best approach? I tried a separate "pop-
up" form, but it is behaving like a transactional form.

Regards,

Bryan Brassell


.
 
Back
Top