Filtering

edited November 2009 in FastReport .NET
I am evaluating Fast Reports Basic, and an using vb express 2008.

I have my own preview form setup

Report1.Preview = frmPreview.PreviewControl1
Report1.Show()
frmPreview.ShowDialog()

and I have created my own Form and report (Report1 with storeinreport set to true.)

I have a combobox on my form and various other textboxes etc. and I have a print button which uses above code.

I want my report to filter which combobox item is select and only preview that item, how can I achieve this.

My form exists in myApp as frmContacts (it is not a built in form in fastreport)

Comments

  • edited 12:04PM
    Hello,

    You have to pass the selected combobox value to a report parameter, before you run a report:

    report1.SetParameterValue("selectedItem", the_selected_item)

    and use this paramater in the databand's filter, something like this:

    [MyTable.MyColumn] == [selectedItem]
  • edited 12:04PM
    Thanks that worked great.

    One other question

    How can I load a saved report through my on preview window, I have tried:

    ReportSelectedPersonal.Preview = frmPreview.PreviewControl1
    ReportSelectedPersonal.Load(Application.StartupPath & "\reports\Avery5321-Selected-Personal.frx")
    ReportSelectedPersonal.Show()
    frmPreview.ShowDialog()

    But it appears blank.

    If I take out the 1st and 4th line, it works, but it uses the built in preview.
  • edited 12:04PM
    Hello,

    I have tried to reproduce it in the demo.exe project. I've changed the code a little:
        Private Sub DesignReport()
            Dim form As Form = New Form
            Dim preview As PreviewControl = New PreviewControl
            preview.Parent = form
            preview.Dock = DockStyle.Fill
    
            FReport = New Report
            FReport.Preview = preview
            FReport.Load(tvReports.SelectedNode.Tag.ToString())
            RegisterData()
            FReport.Show()
            form.ShowDialog()
        End Sub
    

    Now, when I click the "Design the report" button, the new form with the preview is opened.
  • edited 12:04PM
    AlexTZ wrote: »
    Hello,

    I have tried to reproduce it in the demo.exe project. I've changed the code a little:
        Private Sub DesignReport()
            Dim form As Form = New Form
            Dim preview As PreviewControl = New PreviewControl
            preview.Parent = form
            preview.Dock = DockStyle.Fill
    
            FReport = New Report
            FReport.Preview = preview
            FReport.Load(tvReports.SelectedNode.Tag.ToString())
            RegisterData()
            FReport.Show()
            form.ShowDialog()
        End Sub
    

    Now, when I click the "Design the report" button, the new form with the preview is opened.

    Thanks for that.

    I think you have misunderstood, I dont want a user to load or edit or design a report. All I want is my *.frx to appear in my preview window.
  • edited 12:04PM
    No, I have understood you correctly. This code demonstrates how to show a report in a separate window with PreviewControl on it.
  • edited 12:04PM
    AlexTZ wrote: »
    No, I have understood you correctly. This code demonstrates how to show a report in a separate window with PreviewControl on it.

    My apologies, I just thought becuase there was no reference to "Application.StartupPath & "\reports\Avery5321-Selected-Personal.frx" (myreport), then it wouldn't work, but I will try.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.