Filter Bound Report By Parameter In FetchData Event

  • zanebclark 2 months ago

    ActiveReports 6 is built into a software package that my client has adopted. The software does not allow me to add parameters via the element tree. I can add parameters in the ReportStart event and the user will be prompted for a value when running the report. I need to use this parameter value to “filter” the recordset before the report’s group headers are formatted. I would append the parameters to the data control, but I don’t believe I can edit the data control via the software package I am stuck with. If I filter the records in the DetailFormat event, the group headers are already printed and the cross section boxes are sized according to the unfiltered report. The FetchData event is automatically formatted as follows:

    Function ActiveReport_FetchData(ByVal EOF as Boolean) as Boolean
    	ActiveReport_FetchData = EOF
    End Function

    Will the FetchData event fire for every record of a bound report? If it does, I could write a conditional statement that would toss out the values that I don’t want based on the parameter I declare in the ReportStart event. How would I tell ActiveReports 6 to toss out a record in the FetchData event? I can’t rightly set it equal to null, as this would still cause the record to print.

    More than anything, I would love to be able to query the data myself without the sub-par GUI that this particular software has wrapped ActiveReport6 in. I have full access to the server that the data is stored on, but I cannot find any mention of ActiveReports6 or an SQL server with the data I want on it. I don’t know where it is running or from what location it gets its data. What is the traditional implementation of ActiveReports 6? What sort of structure does it rely on?

  • 18p
    Ruchir Agarwal18p 1 month, 4 weeks ago

    Hello,

    You may pass Parameters to your report without even using the Report Explorer. This can be done by passing parameter in the Sql Query itself. In Section report, you can use special syntax in your query to add one or more parameters to the report’s parameter collection, as follows:

    Select * from Customers Where Country =’< %CountryParam|Enter a Country Name|Brazil|S|True%>‘

    The above query will filter the Country table on Country field by prompting the user to enter a country name.
    For more information, please refer to the following Documentation link:

    http://arhelp.grapecity.com/webhelp/Legacy/ActiveReports6/webframe.html

    Also to query related to FetchData event, yes Fetch Data event is fired for every record and you may conditionally show/hide specific records. For this inside FetchData event, check the value of the Field on which you wish to show/hide record then using a Boolean variable inside DetailFormat event set the LayoutAction property to NextRecord, doing this will skip rendering the current and make report render the next record, as follows:

    Dim flag As Boolean = False
        Private Sub MainRpt_FetchData(sender As Object, eArgs As FetchEventArgs) Handles MyBase.FetchData
            flag = False
            If Me.Fields(“ContactTitle”).Value = “Sales Associate” Then
                flag = True
            End If
        End Sub
    
        Private Sub Detail1_Format(sender As Object, e As EventArgs) Handles Detail1.Format
            If flag Then
                Me.LayoutAction = LayoutAction.NextRecord
            End If
        End Sub

    Hope it helps.

    Thanks,
    Ruchir Agarwal

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.