GrandMasterTuck
In need of medication
- Local time
- Today, 15:43
- Joined
- May 4, 2013
- Messages
- 129
[SOLVED] Set a Subform's SourceObject from a different subform on the main form
Hi folks.
I have frmMain, and on frmMain is a tab-control with a control called tabPeople. This tab-control has two controls, both on the same tab: ctlPeopleList (a subform control that shows sbfmPeopleList, a continuous form with all employee records in it) and ctlCardPreview (a subform control who's control source I wish to dynamically set). ctlCardPreview needs to display one of three reports: rptEmployee, rptContractor, or rptManager.
What I want to do is choose which report to show in ctlCardPreview by double-clicking a record in ctlPeopleList . ctlPeopleList has a field called [EmployeeType] which is set to either Employee, Contractor or Manager for all records. I want the system to choose which report to put in that ctlCardPreview control by looking for a report that matches the name of the EmployeeType.
Is the most elegant way to do this with VBA or a Macro (can it even be done with a Macro?)?
I tried to create a VBA Function called SetCardType() with the following code that executes on double-click for that record on ctlPeopleList:
Also tried this:
And this:
...aaaaand it doesn't work. Any ideas? Again, this needs to take data from a record on ctlPeopleList (the recordID and EmployeeType) and use the recordID to choose which record to fetch and use the EmployeeType to choose which report shows up in ctlCardPreview. Two separate controls on the same subform. Neither of the controls is embedded in the other (no forms inside forms, other than the subform inside the tab control with these two offending subforms... confusing, I know..)
Thanks for any help you guys are able to give!
Hi folks.
I have frmMain, and on frmMain is a tab-control with a control called tabPeople. This tab-control has two controls, both on the same tab: ctlPeopleList (a subform control that shows sbfmPeopleList, a continuous form with all employee records in it) and ctlCardPreview (a subform control who's control source I wish to dynamically set). ctlCardPreview needs to display one of three reports: rptEmployee, rptContractor, or rptManager.
What I want to do is choose which report to show in ctlCardPreview by double-clicking a record in ctlPeopleList . ctlPeopleList has a field called [EmployeeType] which is set to either Employee, Contractor or Manager for all records. I want the system to choose which report to put in that ctlCardPreview control by looking for a report that matches the name of the EmployeeType.
Is the most elegant way to do this with VBA or a Macro (can it even be done with a Macro?)?
I tried to create a VBA Function called SetCardType() with the following code that executes on double-click for that record on ctlPeopleList:
Code:
Forms!frmMain!tabPeople.Form!ctlCardPreview.SourceObject = "Report.rpt" & [EmployeeType]
Also tried this:
Code:
Me!ctlCardPreview.SourceObject = "Report.rpt" & [EmployeeType]
And this:
Code:
Me.ctlCardPreview.SourceObject = "Report.rpt" & [EmployeeType]
...aaaaand it doesn't work. Any ideas? Again, this needs to take data from a record on ctlPeopleList (the recordID and EmployeeType) and use the recordID to choose which record to fetch and use the EmployeeType to choose which report shows up in ctlCardPreview. Two separate controls on the same subform. Neither of the controls is embedded in the other (no forms inside forms, other than the subform inside the tab control with these two offending subforms... confusing, I know..)
Thanks for any help you guys are able to give!
Last edited: