[AccessD] Set Recordsource of sub Form

Max Wanadoo max.wanadoo at gmail.com
Tue Apr 15 15:17:42 CDT 2008


Rocky,
You may also find this useful for the future:-

I have a list of buttons on a sub form (PeoplePopSub1) and when a user
clicks one, the second sub form changes.

Here is an example where the user clicked to see a person addresses:

[Forms]![MCM_Peoplemainform]![PeoplePopSub2].SourceObject =
"MCM_PeoplePopAddress"

Click on the NAME Tab of the properties and MAKE SURE you have the correct
<NAME> for the sub form (in my example it is PeoplePopSub2)

Here is how it is used.
On the click event of the button ADDRESSES I have:-

OnMouseDown event I have =pfOpenPeoplePopForms("MCM_PeoplePopAddress")
OnKeyUp event I also have the same
=pfOpenPeoplePopForms("MCM_PeoplePopAddress")

in the function I have:

Public Function pfOpenPeoplePopForms(strForm As String)
' set the subform and link to person in main form
  [Forms]![MCM_Peoplemainform]![PeoplePopSub2].SourceObject = strForm
  If strForm = "MCM_PeoplePopInitial" Then
    [Forms]![MCM_Peoplemainform]![PeoplePopSub2].LinkChildFields = ""
    [Forms]![MCM_Peoplemainform]![PeoplePopSub2].LinkMasterFields = ""
  Else
    [Forms]![MCM_Peoplemainform]![PeoplePopSub2].LinkChildFields =
"PersonID"
    [Forms]![MCM_Peoplemainform]![PeoplePopSub2].LinkMasterFields =
"PersonID"
  End If
End Function

As you can see, I also change the links in this function

HTH
Max




More information about the AccessD mailing list