Q: vb access subform with onclick button Firstly, I know my problem kinda simple, but I am very new on this.
I have a form that contains button (generate_btn), subform (result_sbfrm), table (table1). The goal is, I want my subform display the result of a query after I click the button.
Here is the code I have made:
Private Sub generate_btn_Click()
    Dim qry As String
    qry = "select * from Table1;"
    Me.result_sbfrm.Form.RecordSource = qry
End Sub

It returns error 2467 "the expression you entered refers to an object that is closed or doesn't exist."
Debug stops at "Me.result_sbfrm.Form.RecordSource = qry"

A: As the error message is telling you, you are trying to set the record source of an object that is closed so open it first.
Its a long time since I have worked with VBA or Access but something like.....
Private Sub generate_btn_Click()
    Dim qry As String
    qry = "select * from Table1;"
    DoCmd.OpenForm "result_sbfrm"
    Forms!result_sbfrm.RecordSource = qry 
End Sub

