What I have now is the following:
Code:
Public Sub OpenForm(frm As String, Optional qry As String)
Subform.SourceObject = frm
If qry <> "" Then
Subform.Form.RecordSource = qry
End If
Subform.Visible = True
End Sub
This code is called in the main form. When a button in the mainform is clicked, the subform control is bound. When a detail form needs to be shown, the qry parameter is set with the right query to show one record (select * from tasks where id = 1).
Is this optimal? Now I rebuild the query everytime. Isn't there a way to bound a form to a parameterized query in designtime and set the parameter of this query in runtime?