Happy Holidays Experts,
I have some code that has been working for years but new business rules required me to make to some updates. I have some code that creates a report (expense invoice) and export it to PDF via DoCmd.OutputTo acOutputReport. New business rules now require me to capture some data from the report as its being created which I'm doing in the report groupheader_print. Below is the order in which the code should work:
Note: If i remove the #2 everything works as it should. Like i said this code has been working for years. I'm clueless here.
I have some code that has been working for years but new business rules required me to make to some updates. I have some code that creates a report (expense invoice) and export it to PDF via DoCmd.OutputTo acOutputReport. New business rules now require me to capture some data from the report as its being created which I'm doing in the report groupheader_print. Below is the order in which the code should work:
- Open report (works)
Code:DoCmd.OpenReport rptName, acViewPreview, , "ProjectNum='" & ProjectNum & "' AND ClientID=" & ClientID, acHidden
- Run code to capture data (works)
Code:Private Sub GroupHeader0_Print(Cancel As Integer, PrintCount As Integer) 'Add expense record to Invoice Archive Dim db As Database Dim rs As Recordset Dim rs1 As Recordset Set db = CurrentDb Set rs = db.OpenRecordset("SELECT * FROM qryInvoiceArchiveExpense WHERE ClientID=" & Me.ClientID & "AND ProjectNum='" & Me.ProjectNum & "'", dbOpenDynaset, dbSeeChanges) Set rs1 = db.OpenRecordset("tblFeeServiceInvoiceExpense", dbOpenDynaset, dbSeeChanges) Do Until rs.EOF With rs1 .AddNew !ExpenseID = rs.Fields("ExpenseID") !InvoiceNum = IncrementalInvoiceNum !QtyCompleted = rs.Fields("ExpenseQty") !rTotal = rs.Fields("ExpenseAmountTotal") !ClientID = rs.Fields("ClientID") !ProjectNum = rs.Fields("ProjectNum") .Update rs.MoveNext End With Loop rs.Close rs1.Close Set rs = Nothing Set rs1 = Nothing Set db = Nothing End Sub
- DoCmd.OutputTo acOutputReport (code quits here after i see the pop showing the export is happening. report is not exported. there is no error msg)
Code:DoCmd.OutputTo acOutputReport, rptName, acFormatPDF, strPathAttach, showpdf
- Run some other misc code to do some updates
- close report
- Loop to the next record
- Repeat at #1
Note: If i remove the #2 everything works as it should. Like i said this code has been working for years. I'm clueless here.