Report opens twice when using a stored procedure

Posted by: storms-dd on 4 August 2017, 3:13 pm EST

  • Posted 4 August 2017, 3:13 pm EST

    Please help!


    I changed a report from using a SQL statement with an ADO control, to executing a stored procedure.  Now the report opens twice when I click the command button to open the report.  Thank you!  Here is my code:


    Option Explicit
    Option Base 0

    Private sdate
    Public rptType As Integer

    Public Property Get TheDate() As String
        TheDate = sdate
    End Property

    Public Property Let TheDate(ByVal sNew As String)
        sdate = sNew
    End Property

    Private Sub ActiveReport_ReportStart()
        Dim sSQL As String

        Field1.Text = Me.TheDate

        Me.MousePointer = vbHourglass
        Me.Printer.Orientation = vbPRORLandscape

        arManInsp.TheDate = Me.TheDate

        Dim ADOrs As adodb.Recordset
        Set ADOrs = New adodb.Recordset
        Dim oConnection As adodb.Connection
        Set oConnection = New adodb.Connection
        Dim oCommand As adodb.Command
        Set oCommand = New adodb.Command

        With oCommand
            .ActiveConnection =
            .CommandType = adCmdStoredProc
            .CommandText = "GetDailyInspectionList"
            .Parameters.Append .CreateParameter("@RETURN_VALUE", adInteger, adParamReturnValue)
            .Parameters.Append .CreateParameter("@RptDate", adDate, adParamInput, , Me.TheDate)
        End With

        arManInsp.Printer.Orientation = ddOLandscape

        Set ADOrs = oCommand.Execute
        Set dcmain.Recordset = ADOrs

        Me.MousePointer = vbNormal

    End Sub

  • Replied 4 August 2017, 3:13 pm EST


    Can you please explain a little bit more about this line of code:

    Set dcmain.Recordset = ADOrs

    You may also view following Knowledge Base article which provides more information on how to use Stored Procedures with Active Reports:

    Do let me know if you require further assistance/clarifications.

    Best Regards,


  • Replied 4 August 2017, 3:13 pm EST

    Thank you for your reply, Amit.

    I don't know if I still need this control or not, but "dcmain" is the name of my ADO control.

    Let me know if I can answer any other questions.


  • Replied 4 August 2017, 3:13 pm EST

    Hi Jeff,

    Have you tried the sample application from Knowledge Base article?

    If the KB sample works, then please provide us a small sample application in which report is opening twice when using the Stored Procedures.

    Any further information to isolate the issue would be highly appreciated.

    Best Regards,


Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels