access an unbound report in the viewer on a form

Posted by: joebananas on 4 August 2017, 2:57 pm EST

  • Posted 4 August 2017, 2:57 pm EST

    I currently have a working unbound report that I need to change to a report that displays through the viewer in a VB form. I currently load the values on the report like this,

    Private Sub mnuFilePrintBarCode_Click()
        With arBarcodeLabel
            .brcMain = value1
            .lblDescription = value2
            .lblVendorPartNum = value3
            .Show
        End With
    End Sub

    Now I've created a new form with the viewer control on it and I hoped I could load the values like this,

    Private Sub mnuFilePrintBarCode_Click()
        Dim rptBarcode As Form
        Set rptBarcode = New frmReport
       
        rptBarcode.arvMain.ReportSource = arBarcodeLabel
        With rptBarcode.arvMain.ReportSource
            .brcMain = value1
            .lblDescription = value2
            .lblVendorPartNum = value3
        End With
        rptBarCode.Show
    End Sub

    but this doesn't work. The form appears and the viewer is displayed but the data fields don't have the correct data. Can anyone help me with this.

    - Thanks
  • Replied 4 August 2017, 2:57 pm EST

    Joebananas,


    Try to set the values of the controls on the report before setting the ReportSource. That is, create a new report object, set the values you need to, then set it to the ReportSource. Currently, it appears you may be setting the values after the report has already been run.


    For example ...


    Dim arBarcodeLabel as New YourReport


    With arBarcodeLabel
        .brcMain = value1
        .lblDescription = value2
        .lblVendorPartNum = value3
    End With


    rptBarcode.arvMain.ReportSource = arBarcodeLabel


    Tim

  • Replied 4 August 2017, 2:57 pm EST

    Thanks for the help. That was it; everything seems to work fine now.
Need extra support?

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

Learn More

Forum Channels