Note that there are some explanatory texts on larger screens.

plurals
  1. POBind Access Form/Report to results from MySQL Stored Procedure
    primarykey
    data
    text
    <p>I'm trying to change the recordset of a Report (or Form) to be the results of a dynamically called MySQL stored procedure, in the Report_Load event. Specifically, how would I set up the connection?</p> <p>I've looked at <a href="https://stackoverflow.com/questions/4784820/bind-access-form-to-the-results-from-a-stored-procedure">Bind Access form to the results from a Stored Procedure</a>, as well as <a href="http://support.microsoft.com/kb/281998/en-us" rel="nofollow noreferrer">How to bind Microsoft Access forms to ADO recordsets</a>. I'm already successfully connecting to the stored procedure using hard-coded values in a pass-thru query, as detailed in <a href="http://forums.mysql.com/read.php?65,278515" rel="nofollow noreferrer">Calling Stored Procedures and other SQL statements from MS Access 2003 (Pass Through)</a>.</p> <p>Here's the example code from <a href="https://stackoverflow.com/questions/4784820/bind-access-form-to-the-results-from-a-stored-procedure">Bind Access form to the results from a Stored Procedure</a> - I want to setup the connection to use MySQL instead of SQL Server:</p> <pre><code>With cn .Provider = "Microsoft.Access.OLEDB.10.0" .Properties("Data Provider").Value = "SQLOLEDB" .Properties("Data Source").Value = "Server" .Properties("Integrated Security").Value = "SSPI" .Properties("Initial Catalog").Value = "Test" .Open End With </code></pre> <p>I'm using Access 2007.</p> <hr> <p>Out of interest, here is the code I was using to try to modify the sp call, giving an error "32585 this feature is only available in an ADP". Gord Thompson's suggestion of modifying the actual query works, so I'm using that.</p> <pre><code> If Not CurrentProject.AllForms("foo_frm").IsLoaded Then 'use hard-coded query (stored procedure) for dev work Exit Sub End If Dim action, startdate, enddate As String action = Forms![foo_frm].txtAction If action = "cmdDaily" Then startdate = Forms![foo_frm].txtYesterday enddate = Forms![foo_frm].txtToday Else startdate = Forms![foo_frm].cboStartDate enddate = Forms![foo_frm].cboEndDate End If Dim cn As New ADODB.Connection Dim strConnection As String strConnection = "ODBC;DSN=Foo01;UID=root;PWD=Secret;DATABASE=bar" With cn .Provider = "MSDASQL" .Properties("Data Source").Value = strConnection .Open End With Dim prmStartDate, prmEndDate As New ADODB.Parameter Dim cmd As New ADODB.Command Set prmStartDate = cmd.CreateParameter("startdate", adDate, adParamInput) prmStartDate.Value = CDate(startdate) cmd.Parameters.Append (prmStartDate) Set prmEndDate = cmd.CreateParameter("enddate", adDate, adParamInput) prmEndDate.Value = CDate(enddate) cmd.Parameters.Append (prmEndDate) With cmd .ActiveConnection = cn .CommandText = "qux_sp" .CommandType = adCmdStoredProc Set Me.Recordset = .Execute End With </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload