title: Bind Access form to the results from a Stored Procedure
body: <p>I am trying to return the results of a stored procedure to a form. I have managed to iterate thru the results using an ADO recordset, but cannot bind the results to the form.. </p>
  
  <p>Here is the VBA code:</p>
  
  <pre><code>Private Sub RetrieveSiteInformation()
  
    Dim cmd As New ADODB.Command
    Dim cnn As New ADODB.Connection
    Dim rs As ADODB.Recordset, f As ADODB.Field
  
    With cnn
      .Provider = "SQLOLEDB"
      .ConnectionString = 
          "data source=UKFCSVR;initial catalog=ACACB;Trusted_Connection=Yes"
      .Open
    End With
  
    Dim param1  As ADODB.Parameter
    If Nz(txtSiteID_Search.Value, vbNullString) &lt;&gt; vbNullString Then
      Set param1 = cmd.CreateParameter("@SiteID", adBigInt, adParamInput)
      param1.Value = txtSiteID_Search.Value
      cmd.Parameters.Append param1
    End If
  
    With cmd
     .ActiveConnection = cnn
     .CommandText = "spSiteInformation_Retrieve"
     .CommandType = adCmdStoredProc
      **' THIS FAILS**
      Me.Recordset = .Execute
      **' THIS LOOP WORKS FINE**
      '    Set rs = .Execute
      '    rs.MoveFirst
      '    For Each f In rs.Fields
      '      Debug.Print f.Name
      '    Next
      '    With rs
      '      Do While Not .EOF
      '        Debug.Print ![CompanyName] &amp; " " &amp; ![Postcode]
      '        .MoveNext
      '      Loop
      '    End With
    End With
    cnn.Close
  End Sub
  </code></pre>