When the user selects a record in the subform and then clicks on the button on the main form, it opens up to another form(filtered form) that contains the history of the selected record).
To obtain a filtered recordset, I created and executed a recordset through a stored procedure in the click event procedure. I am not sure how I can populate the form with the recordset from the stored procedure. I did a debug.print on the recordset and right results displayed.


**I want the results from the stored procedure as the recordsource for the form I want to open to.***

This is what I have:
Private Sub w_o__history_Click()

On Error GoTo Err_w_o_history_Click

Dim ret_val As Integer
Dim check_wo_history As New ADODB.Command
Dim rs_check_wo_history As New Recordset
Dim work_ord_num As String, work_ord_line_num As String
Dim lngRecs As Long
Dim stDocName As String, stLinkCriteria As String, strWhere As String

stDocName = "shipment_hist_list"
strWhere = "tblShipment_history!work_ord_num = Me!shipping_sched_list_subform.Form!work_ord_num"

Call load_const


' ensure that the Work order number is on the tblShipment_history
With check_wo_history

.ActiveConnection = CurrentProject.Connection
.CommandText = "spCheck_wo_history"
.CommandType = adCmdStoredProc
.Parameters.Append .CreateParameter("ret_val", adInteger, adParamReturnValue)
.Parameters.Append .CreateParameter("@work_ord_num", adChar, adParamInput, work_ord_num_length, Me!shipping_sched_list_subform.Form!work_ord_num.V alue)
.Parameters.Append .CreateParameter("@work_ord_line_num", adChar, adParamInput, 3, Me!shipping_sched_list_subform.Form!work_ord_line_ num.Value)
Set rs_check_wo_history = .Execute(recordsaffected:=lngRecs)

End With
Debug.Print lngRecs

If lngRecs <> 0 Then
Do While Not rs_check_wo_history.EOF
DoCmd.OpenForm FormName:=stDocName
Debug.Print rs_check_wo_history(0)
rs_check_wo_history.MoveNext
Loop
End If


Exit_w_o_history_Click:

Set check_wo_history = Nothing
Exit Sub

Err_w_o_history_Click:
MsgBox Err.Description
Resume Exit_w_o_history_Click

End Sub

Your help is greatly appreciated!