combobox filter

A

AliKural

Hi everybody

My problem is about combo box filters. I have two combo
boxes one is for main category and one is for sub
category. When you choose the main ctg. from the first
combo, the second combo box shows the sub categories
belonging to that main ctg. i'm ok with that.

When i use this in subform it works for the first line.
When i go to the second line and choose a diffrent main
category, the sub category on the first line is erased, i
mean not from the table, but from the screen. I tried
refreshpage on main forms it worked, but in the subform it
didn't.

Is there a solution for that.

Thank you in advance and regards.

NOTE : Main ctg table fields(main_ctg_id;main ctg)
Sub ctg table fields(sub_ctg_id;sub_ctg;main_ctg_id
(as foreign key))

In sub ctg. combo box query, i add a criteria to
main_ctg_id as the main ctg. combo control name on that
form.
 
M

Marc

mean not from the table, but from the screen. I tried
refreshpage on main forms it worked, but in the subform it
didn't.

You need to do a requery of the subcategory combobox in the onchange event
of the main category.
HTH
Marc
 
V

Van T. Dinh

Do you use a Form in ContinuousFormView as the Subform?

If you do, that's the problem since what you see is many instances of the
the *same* ComboBox Control and since it is the same Control, you can only
have 1 RowSource. Thus, all instances will have the same RowSource. If the
value of the ComboBox in the first row is no longer in the RowSource, the
ComboBox instance in the first row will show blank (the value is still
there).

What you can do is to create 2 ComboBox Controls (or a TextBox and the
filtered ComboBox) occupying the same space, one is dynamically filtered
according to the main category, one is unfiltered which has all
sub-categories in the RowSource. Bring the unfiltered ComboBox to Front of
the filtered ComboBox. Bind both ComboBox to the same required Field in
your (Subform's) RecordSource. Add the code in the GotFocus Event of the
unfiltered ComboBox to send the Focus to the filtered ComboBox.

This way, the instances of the unfiltered ComboBox always shows the chosen
values (since all values are in the RowSource). In the current row (for
current data entry, says), when the user move to the Focus to the unfiltered
ComboBox, the filtered ComboBox will get the Focus (it will come to the
front covering the unfiltered ComboBox) which has only filtered choices.
You can even drop the list down (DropDown Method) automatically for the use
to select.
 
A

AliKural

In fact i have a code on "Afterupdate" event of the main
category combo ctrl., which requeries the sub ctg. combo
box control, but it doesn't work. I mean in the second
line of subform (where the subform is in datasheet view)
if i have the same main category as the first line it
works, but if i change the main category, the sub category
on the first line becomes invisible.

Thx for reply.
 
A

AliKural

Thx for the idea, i think i got your point with that, but
the subform is in datasheet view, so both controls will
show as diffrent columns. I can design the subform in
continuous view, but i still wonder if there is a way to
show the values in datasheet view. I got to this point
cause i had the same problem in the main form, but i added
refreshpage macro to afterupdate event of the main ctg.
and the problem was solved.

Thank you in regard.
 
M

Marc

Have you tried it in the onchange?
Marc
AliKural said:
In fact i have a code on "Afterupdate" event of the main
category combo ctrl., which requeries the sub ctg. combo
box control, but it doesn't work. I mean in the second
line of subform (where the subform is in datasheet view)
if i have the same main category as the first line it
works, but if i change the main category, the sub category
on the first line becomes invisible.

Thx for reply.
 
V

Van T. Dinh

Not sure about DatasheetView of the Subform. I always use CtsFormView which
can be designed to look like a Datasheet.
 

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