Posted on 2009-04-06
Last Modified: 2012-05-06
How can i arrange this code to make a stored procedure?
I'm trying to make a stored procedure like an image below but i dont know if ist correct.
hope you correct this code!


	[PCODE] [char] (16) NULL ,

	[PNAME] [char] (45) NULL ,

	[QUANTITY] [float] NULL ,

	[AMOUNT] [float] NULL ,

	[DISCOUNT] [float] NULL ,

	[PROFIT] [float] NULL ,

	[THEDATE] [datetime] NULL ,

	[SALESTYPE] [char] (1) NULL ,

	[TRXNO] [float] NULL ,

	[SOP] [float] NULL 



Open in new window

Question by:Whing Dela Cruz
LVL 11

Accepted Solution

bmatumbura earned 500 total points
ID: 24084274
What is the procedure supposed to do?

Author Comment

by:Whing Dela Cruz
ID: 24084373
to exe.command

Public Function ChkSoldItem( _

    ByRef pCode As String, _

    ByRef TheDate As Date, _

    ByRef SALESTYPE As String) As Boolean


Dim cnn As ADODB.Connection

'On Error GoTo Handle_Err

  Const conProcName = conModuleName & _



    Dim cmd As ADODB.Command

    Dim prms As ADODB.Parameters

    Dim rs As ADODB.Recordset


    Set cnn = New ADODB.Connection

    cnn.ConnectionString = conConnectionString


    If Not cnn.State = adStateOpen Then

      GoTo Exit_Here

  End If

' Create command objects

    Set cmd = New ADODB.Command

' Set command properties

With cmd

    Set .ActiveConnection = cnn

    .CommandText = "chksolditem"

    .CommandType = adCmdStoredProc

    Set prms = .Parameters

End With

    ' Define stored procedure prms and append to command.

    prms.Append cmd.CreateParameter("@pcode", adChar, adParamInput, 16)

    prms.Append cmd.CreateParameter("@thedate", adDate, adParamInput, 0)

    prms.Append cmd.CreateParameter("@salestype", adChar, adParamInput, 1)



    ' Insert a dummy customer

    prms("@pcode") = pCode

    prms("@thedate") = TheDate

    prms("@salestype") = SALESTYPE

    ' Execute the command

    Set rs = cmd.Execute

    With rs

        If .BOF = True And .EOF = True Then

            ChkSoldItem = False


            ChkSoldItem = True

        End If


    End With

    ' Retrieve stored procedure return value and output parameters


  ' Ensure that connection is closed and released.

  If Not cnn Is Nothing Then

      If cnn.State = adStateOpen Then


      End If

      Set cnn = Nothing

  End If

  Exit Function



  Select Case Err.Number

    Case Else

        Err.Raise Err.Number, _

          conProcName, Err.Description, _

          Err.HelpFile, Err.HelpContext

  End Select

  Resume Exit_Here


End Function

Open in new window


Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Add a task in Outlook from access 11 35
Hide vba in gp 7 83
Passing a Text Box name to a Sub 6 75
MS Access 03, TransferText, decimal places 8 45
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now