问题
Dim newRS
newRS = "SELECT DISTINCT [Grp_ID], [Group_Name], [Group_NPI] FROM [GROUP]"
Forms!loclistingfrm!LocationListSubFrm.RecordSource = newRS
When I look at the LocationListSubFrm sub form in Design View, there is no Record Source property. However, when I access it directly from the objects pane I can see it.
Is the fact that it's a subform preventing me from changing the record source? The same subform is recycled throughout my application, so I can't really edit it at the source.
回答1:
Do note, that you need to address the subform control, not the (sub)form itself:
Dim newRS As String
newRS = "SELECT DISTINCT [Grp_ID], [Group_Name], [Group_NPI] FROM [GROUP]"
Me!NameOfYourSubformControl.Form.RecordSource = newRS
回答2:
Try adding .form.recordsource as shown below.
Dim newRS
newRS = "SELECT DISTINCT [Grp_ID], [Group_Name], [Group_NPI] FROM [GROUP]"
Forms!loclistingfrm!LocationListSubFrm.form.RecordSource = newRS
来源:https://stackoverflow.com/questions/42168426/setting-the-record-source-of-a-subform-in-access