jd_boss_hogg
Registered User.
- Local time
- Today, 09:05
- Joined
- Aug 5, 2009
- Messages
- 88
Hoping some kind hearted sole can help me....(i'm a novice).
I have the following code running from a button on a form, which uses "NewCsvExport" query as its record source. I want to open and print a report for each record in the query. When running, i just bomb straight out to 'on error'. I think its maybe the way i have my recordset set up ?
I have the following code running from a button on a form, which uses "NewCsvExport" query as its record source. I want to open and print a report for each record in the query. When running, i just bomb straight out to 'on error'. I think its maybe the way i have my recordset set up ?
Code:
Private Sub Command18_Click()
On Error GoTo Export_Invoice_Err
Dim rstJobs
Dim dbs As DAO.Recordset
DoCmd.OpenQuery "NewCsvExport", acViewNormal, acReadOnly
Set rstJobs = dbs.OpenRecordset("NewCsvExport", dbOpenDynaset)
If rstJobs.BOF And rstJobs.EOF Then
Exit Sub ' empty record set, nothing to do here
End If
Do While Not rstJobs.EOF
' print invoices to emails'
DoCmd.OpenReport "PDFInvoiceUK", acViewNormal, , [Rate] = "T1" Or "T0" And [IN_VIA] <> "Re-Make"
DoCmd.OpenReport "PDFInvoiceEurope", acViewNormal, , [Rate] = "T4" And [IN_VIA] <> "Re-Make"
DoCmd.OpenReport "PDFInvoiceForeign", acViewNormal, , [Rate] = "T9" And [IN_VIA] <> "Re-Make"
rstJobs.MoveNext
Loop
DoCmd.Close acQuery, "NewCsvExport"
DoCmd.OpenReport "Invoices_to_sage"
DoCmd.OpenQuery "NewCsvNotExported"
Forms!New_CSV_export!.Refresh
MsgBox "All Done !"
Exit Sub
Export_Invoice_Err:
MsgBox "Problems !"
End Sub