I have a subform where its recordsource property is switched to a temp recordset variable when the main form is opened.
I now need to amend the main form so that the subform recordsource is reset to sql if certain options are selected by the user on the main form. My code is bombing out when I try and reset the recordsource property as follows:
Set frm = Forms("FrmName")
Set ctl = frm.Controls("FrmName")
sql = "SELECT Tbl.......etc etc"
ctl.Form.RecordSource = sql
The error number is run-time error 31 (data provider could not be initiated).
I have tested the sql statement and it works fine. It is just a simple selection of records from an existing table in the local database
I seem to need another statement to re-establish the link between the form and the original data source.
Any ideas?
I now need to amend the main form so that the subform recordsource is reset to sql if certain options are selected by the user on the main form. My code is bombing out when I try and reset the recordsource property as follows:
Set frm = Forms("FrmName")
Set ctl = frm.Controls("FrmName")
sql = "SELECT Tbl.......etc etc"
ctl.Form.RecordSource = sql
The error number is run-time error 31 (data provider could not be initiated).
I have tested the sql statement and it works fine. It is just a simple selection of records from an existing table in the local database
I seem to need another statement to re-establish the link between the form and the original data source.
Any ideas?