Greetings,
I'm trying to utilize VBA to set a subform's recordsource on a command button click. My form is used to search by a query and display the results in the subform. If I set the subform source in the property sheet it works properly but loads the full query on opening the form. I want the subform to be blank until I click the search button. Here is my button's code:
When I click the button I get an error stating:
The expression you entered refers to an object that is closed or doesn't exist.
Is this an error in my button code or a consequence of my form to query interaction?
Thank you
RL
I'm trying to utilize VBA to set a subform's recordsource on a command button click. My form is used to search by a query and display the results in the subform. If I set the subform source in the property sheet it works properly but loads the full query on opening the form. I want the subform to be blank until I click the search button. Here is my button's code:
Code:
Private Sub btnSearch_Click() On Error GoTo btnSearch_Click_Err Forms![frmQuickSearchMedia]![Media Search subform].Form.RecordSource = "Media Search" Forms![frmQuickSearchMedia]![Media Search subform].Form.Requery btnSearch_Click_Exit: Exit Sub btnSearch_Click_Err: MsgBox Error$ Resume btnSearch_Click_Exit End Sub
The expression you entered refers to an object that is closed or doesn't exist.
Is this an error in my button code or a consequence of my form to query interaction?
Thank you
RL
Comment