Problems with filter in subforms

mrmozambique

Registered User.
Local time
Today, 18:33
Joined
May 20, 2009
Messages
16
Hi all.

I've been struggling with this the last several days and just can't seem to get it straightened out. It's a DB for tracking HIV/AIDS health data at an NGO in Vietnam.

I have a main form with four subforms all tied together with mother/child link field. All subforms are invisible until you select an unbound combo on the main form. There's an afterupdate event on the unbound combo that shows the appropriate subform and hides all others. This works fine.

However, my subform doesn't filter the items correctly. Each subform should be filtering out items related to the category selected in the unbound combo on the main form. Since the number of options is relatively limited, I've just hard-coded the IDs into the filter property of the subform. It looks something like this:

Code:
(([program_id]=21) or ([program_id]=22) or ([program_id]=23) or ([program_id]=30) or ([program_id]=31) or ([program_id]=32) or ([program_id]=33) or ([program_id]=34))
I've also tried changing the filter in VBA, something like the below. It's in the VBA code for the main form's unbound combo afterupdate (embedded in some if statements).

Code:
Form_frm_indicators_input_sub_p.Form.FilterOn = False
Form_frm_indicators_input_sub_p.Form.Filter = ([program_id] = 1) Or ([program_id] = 2) Or ([program_id] = 3) Or ([program_id] = 4) Or ([program_id] = 5)
Form_frm_indicators_input_sub_p.FilterOn = True
Note that program_id is a field from the subform's related table and the combo related to that field is cboprogram_id. The property filter returns nothing (although there are certainly records with one or more of the above program_ids) and the VBA returns everything without filtering it.Am I missing some quotes or some other symbol here?? Any ideas why the filter isn't working?

Thanks in advance!
 
Thanks, Bob. Unfortunately, changing it didn't help me.

Another thing that's strange is that even if you hardcode the filter in the subform properties, it doesn't keep after you close the form. It goes back to a blank filter property. Any idea why this happens?

One thing I failed to mention above is that all subforms have the same RecordSource. However, they display varying combinations of fields. They are all continuous forms as well. I'm not sure if this affects my filter.
 

Users who are viewing this thread

Back
Top Bottom