Solved Filtered subform within a Mainform (1 Viewer)

hhag

Member
Local time
Today, 12:17
Joined
Mar 23, 2020
Messages
69
Hi,
I've a subform which is based on a query. The query is based on different tables, and one field is [Initials].
The query and the subform is working perfect when I run it "stand alone".
Now, I want to put this subform in a new form, a mainform, which contains a combobox. I use this control to filter the field [Initials] in the query/subform on.
This combobox has an After_Update event as:

With [subfrmXXXX].Form
.Filter = "[Initials] =" & me.cboInitials.column(1)
.FilterOn = True
End with

The combobox is based on a table, where I've picked two fields from: InitialsID, and Initials.

Does anyone have any idea?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 18:17
Joined
May 7, 2009
Messages
19,233
onclosed your .Filter expression in " character:

.Filter = "[Initials] ='" & me.cboInitials.column(1) & "'"

Or

.Filter = "[Initials] =" & Chr(34) & me.cboInitials.column(1) & Chr(34)

also, you should test first if there is a value on the combo:
Code:
With [subfrmXXXX].Form
    If Me.cboInitials.ListIndex > -1
        'there is selection in combo
        .Filter = "[Initials] =" & Chr(34) & me.cboInitials.column(1) & Chr(34)
        .FilterOn = True
        
    Else
        'combo is blank, this could happen if you delete the value in the combo
        .FilterOn = False
    End If
End with
 

hhag

Member
Local time
Today, 12:17
Joined
Mar 23, 2020
Messages
69
Thanks for your response! I corrected my line according to your first input, but still the subform isn't updated.
So, then I started all over again. I created a new blank form, added the subfrm - Ok, the info is there. Then I added the combobox and got the After_Update event to work as well. Perfect, the filter works.

But, what can be the different between the two 'Mainforms'? Has it anything to do with the data source of the first Mainform?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 18:17
Joined
May 7, 2009
Messages
19,233
it maybe, that the first mainform is corrupt and the event on the combo's afterupdate is not being fired.
 

Users who are viewing this thread

Top Bottom