Home > Back-end >  Get report name from DataSource of subform ms access vba
Get report name from DataSource of subform ms access vba

Time:04-28

I have a form (say form1) to navigate to another form (form2) which has a subform that opens reports based on the DataSource put into by selecting the Text box on form1.

The code looks like this

Private Sub txt_DeliveryItemsSummary_Click()
        DoCmd.OpenForm "frm_viewReports", acNormal
        Forms!frm_ViewReports!subrpt_ReportArea.SourceObject = "Report.rpt_DeliveryItemsSummary"
End Sub

And on form2 I have a print button to print the report The code looks like this

    DoCmd.OpenReport subrpt_ReportArea.SourceObject, acViewNormal, , , acWindowNormal

But this code gives following error

Runtime Error 2103

The report name 'Report.rpt_DeliveryItemsSummary' you entered in either the property sheet or macro is misspelled or refers to a report that doesn't exist.

Any help how can I fix this issue.

Thanks a lot in advance.

CodePudding user response:

Just figured it out myself. I knew i need to skip a piece of text but how! There I was getting trouble.

Here is the working code

    DoCmd.OpenReport Right(subrpt_ReportArea.SourceObject, Len(subrpt_ReportArea.SourceObject) - 7), , acViewNormal, , , acWindowNormal

Thanks @Gustav for reaching out again.

  • Related