Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It sounds like your stored procedure actually returns only one value, which will either be 0 or 1. This is often referred to as a scalar value (a single value instead of a set or collection of values).</p> <p>It also looks like you need to pass parameters to your stored procedure. This is often referred to as a parameterized query. As you probably well know, it's possible to write stored procedures that do not not use parameters.</p> <pre class="lang-vb prettyprint-override"><code>Set con = New ADODB.connection Set rs = New ADODB.Recordset rs.CursorType = adOpenForwardOnly rs.LockType = adLockReadOnly con.Open "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" '// Connection string. Dim cmd as New ADODb.Command cmd.CommandTimeout = 5 cmd.ActiveConnection = con cmd.CommandText = "SQL GOES HERE" cmd.CommandType = acCmdStoredProc Dim param Set param = cmd.CreateParameter("@productid", adInteger, adParamInput, 0, 0) cmd.Parameters.Append param cmd.Parameters("@productid") = 15 'Return the product with ProductID = 15 Set rs = cmd.Execute 'or use: 'rs.Open cmd Debug.Print rs(0) rs.close Set rs = Nothing Set cmd = Nothing con.close Set con = Nothing </code></pre> <p>Microsoft has an article on this. It's written using VBScript but can be easily adapted to VBA. <a href="http://support.microsoft.com/kb/200190" rel="nofollow noreferrer">http://support.microsoft.com/kb/200190</a></p> <p>You might also check out this on SO:<br> <a href="https://stackoverflow.com/questions/3070067/how-to-access-sql-server-scalar-functions-in-ms-access-vb">How to access SQL Server scalar functions in MS Access VB</a></p>
 

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