I have several years experience with VBA in MS Office applications (for automation and ETL processes) but have not had the need to mess with Forms in MS Access until recentl
If the "object that is closed or doesn't exist" error occurs on the Me.dataDisplaySubform.Form.RecordSource
line, chances are your subform control is not named dataDisplaySubform.
You can examine the names of all your form's subform controls with this temporary change to your code ...
'Me.dataDisplaySubform.Form.RecordSource = pSQL
Dim ctl As Control
For Each ctl In Me.Controls
If TypeName(ctl) = "SubForm" Then
Debug.Print ctl.Name, TypeName(ctl)
End If
Next
Stop
The Stop
statement will trigger debug (break) mode and take you to the Immediate window where you can view the names of your form's subform control(s).
The screenshot you added to the question confirms you're using the correct name for the subform control. However, that subform has nothing in its Source Object property. Since there is no form there, the second part of the error message, "doesn't exist", applies. There is no form to be referenced by Me.dataDisplaySubform.Form