Filter Subform from another form

jsic1210

Registered User.
Local time
Today, 01:52
Joined
Feb 29, 2012
Messages
188
Hi everyone. I am trying to filter a subform when I open the parent form from a different form with an option group. So, the first form pops up with the options: 1) Show "Active" Contracts 2) Show All Contracts. If the user selects 1, I want it to open the specific customer form (frmContractsForm) and filter the subform (frmContractSub) where the subform's "Status" field is "Active." Here is my code:
Code:
'Display Active or All Contracts
    'Open Form
        DoCmd.OpenForm "frmContractForm", , , "CustomerID=" & Me.txtCustomerID
    'Filter to Active or All
    Select Case frameOptions
        Case 1
        With Forms!frmcontractform.frmContractSub
            .Filter = "Status= 'Active'"
            .FilterOn = True
        End With
    End Select
Thanks!
Jeff
 
Add a .Form after your subform control reference;

Code:
'Display Active or All Contracts
    'Open Form
        DoCmd.OpenForm "frmContractForm", , , "CustomerID=" & Me.txtCustomerID
    'Filter to Active or All
    Select Case frameOptions
        Case 1
        With Forms!frmcontractform.frmContractSub.[COLOR="Red"]Form[/COLOR]
            .Filter = "Status= 'Active'"
            .FilterOn = True
        End With
    End Select
 
Beetle, thanks for the help, but unfortunately that didn't work. Any other thoughts?
 
I'm still having trouble with this. Does anybody have any suggestions?
 
Can you be more specific about what trouble you're having. Are you getting an error message, or is it just not filtering the records in the subform? Have you double checked the names of all the objects, especially the subform control? The subform control may, or may not have the same name as the subform itself.
 
Sorry, I am not receiving an error message. It's just not filtering. I did check the name of the subform control vs. the name of the subform, but that isn't the issue.
 
Can you re-post your entire procedure, as it is currently written?

Alternatively, if you want to post a copy of your db with just some dummy data I can take a look at it.
 

Users who are viewing this thread

Back
Top Bottom