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

    Catching VALUE OF FORM FOR VARIABLE STORED PROCEDURE, FORM OF GETTING VALUE FOR VARIA

    Hello everybody
    Just recently I started to eat access,
    Delphi is my forte and I'm having doubts about one thing.
    I have a form linked to database access sql server,
    and have a command button that opens when you click a Stored.
    I have 2 stored in this variable, I would like to click
    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 someone could 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

    Please correct me if you are totally wrong, hehe

  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
    Not sure, though the stored procedure name looks odd with the space in it. I think the parameters need the "@" that they have in SQL Server. Here's how I do it (this is just the guts of it):

    Code:
      With cmd
        .ActiveConnection = objConn
        .CommandText = "procResAudit"
        .CommandType = adCmdStoredProc
    
        .Parameters.Append .CreateParameter("@ResNum", adInteger, adParamInput, , lngResNum)
        .Parameters.Append .CreateParameter("@FieldName", adVarChar, adParamInput, 25, strField)
        .Parameters.Append .CreateParameter("@OldValue", adVarChar, adParamInput, 250, varOldValue)
        .Parameters.Append .CreateParameter("@NewValue", adVarChar, adParamInput, 250, varNewValue)
        .Parameters.Append .CreateParameter("@Operator", adInteger, adParamInput, , Forms!frmLogin.txtUserID)
        .Execute
      End With
    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. Pass a form property to a procedure
    By trb5016 in forum Programming
    Replies: 2
    Last Post: 02-17-2010, 04:15 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