Steven
Steven

Reputation: 155

Setting the Record Source of a subform in Access

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.

Upvotes: 2

Views: 3351

Answers (2)

Gustav
Gustav

Reputation: 55806

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

Upvotes: 2

RyanL
RyanL

Reputation: 1276

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

Upvotes: 1

Related Questions