Question : How can I change the recordsource of a subform from a different form?

I have the following database. So the user chooses the firm they want to view from Introform then "Form10" is opened.
In Form10 there is a box with the header "Clients in the Fund" and "Contacts with Manager" (both should be datasheets)
"Clients in the fund" should be fed from "client holding table"
"Contacts with Managers" should be fed from the table "ComCon"

I am guessing both are supposed to be subforms.
So how can I change the recordsources (or any other way that is more efficient) so I can display the required info on these subforms (Datasheets)

thanks
Attachments:
 
 

Answer : How can I change the recordsource of a subform from a different form?

I am unable to open the database at this time.  I'm assuming that your reference to "box" in your question refers to a combo box.  If that is the case, why don't you create a separate form for each of these situations.  Then, based on the selection in the combo box, just change the subforms SourceObject

Private Sub cbo_YourControlName_AfterUpdate

    IF me.cbo_YourControlName = "Clients in the Fund" Then
        me.subFormControlName.SourceObject = "frm_Clients_in_the_Fund"
    Else if me.cbo_YourControlName = "Contacts with Manager"
        me.subformControlName.SourceObject = "frm_Contacts_with_Manager"
    Else
        me.subformControlName.SourceObject = ""
    End if

    me.subformControlName.visible = (me.subformControlName.SourceObject <> "")

End Sub

You will need to replace "subformControlName" with the name of the subform control on Form10.
Random Solutions  
 
programming4us programming4us