Results 1 to 2 of 2
  1. #1
    rodrigopcnet is offline Novice
    Windows XP Access 2000
    Join Date
    Apr 2010
    Posts
    2

    Passing variable values to Stored Procedure


    I have a form linked to database access sql server,
    and have a command button that opens when you click a Stored.
    I have stored this 2 variables, I would click the
    button, pull the value of two fields in the form for the variables to
    thus open the query, I tried in many ways, but failed.
    I wish somebody would help me to
    NAME OF STORED: Form PRD_PRE_PEDIDO_EXPORTA_PROFORMA
    NAME OF VARIABLE: @ @ PPrePedidoCodigo PCodEmpresa and both are type INTEGER
    NAME OF FIELDS IN THE FORM: Me.CodEmpresa and Me.Prepedidocodigo

    Code that did

    Private Sub BtnExportaProforma_Click ()
    Dim cnn As ADODB.Connection
    Dim cmd As New ADODB.Command
    Dim prm The ADODB.Parameter

    Set cnn = CurrentProject.Connection
    Set cnn = cmd.ActiveConnection
    cmd.CommandText = "dbo. [Form PRD_PRE_PEDIDO_EXPORTA_PROFORMA]
    cmd.CommandType = adCmdStoredProc
    Set prm = cmd.CreateParameter (PCodEmpresa "adInteger, adParamInput,, Me.CodEmpresa)
    cmd.Parameters.Append prm
    Set prm = cmd.CreateParameter (PPrePedidoCodigo "adInteger, adParamInput,, Me.PrePedidoCodigo)
    cmd.Parameters.Append prm
    Cmd.Execute
    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    This appears to be a duplicate post:

    https://www.accessforums.net/access/...aria-5270.html
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 04-13-2010, 12:18 PM
  2. Replies: 1
    Last Post: 11-17-2009, 06:55 AM
  3. Replies: 0
    Last Post: 10-04-2009, 04:11 AM
  4. Passing a variable to a form
    By cjamps in forum Forms
    Replies: 0
    Last Post: 03-02-2009, 05:32 AM
  5. stored procedure return value to access form
    By rbw940 in forum Programming
    Replies: 0
    Last Post: 10-13-2008, 01:31 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums