I am trying to print a report that is stored in an access application from a separate VB6 front end. I can get the report to print, but I can't get the code in report_open to run when printing from VB6.
The report is a template for a letter, I am trying to pull information from a database to enter into the letter mid sentence (ie thank you for your donation of ___ to our Annual Drive). I am going about this by forming the sentence programmatically in the report_open code or passed into it in the OpenArgs field.
If I call the report from a form in the access database as such
Then the label in the report says "Testing"Code:Private Sub Command0_Click() DoCmd.OpenReport "Test", acViewReport, , , acWindowNormal, "Testing" End Sub
When I call the report from VB6 with
Then the label in the report says "Default Content" (Default content of the label)Code:Set accessApplication = New Access.Application accessApplication.OpenCurrentDatabase "C:\fire.mdb" accessApplication.DoCmd.OpenReport "Test", acViewDesign, , , acWindowNormal, "Passed into"
Code of the report_open
Another solution would be if I could embed the table values within the label caption field. Something akin to 'Thank you for your donation of &donation.value& to our annual fund drive' but I couldn't find that online either.Code:Private Sub Report_Open(Cancel As Integer) Dim strCaption As String strCaption = Reports!Test.OpenArgs 'strCaption = "Code ran on open!" Reports("Test").Controls("lblBody").Caption = strCaption End Sub


Reply With Quote