I have an Access Database with a form that will print selected reports by group. Which it does fine. But I want the saved file to have the field InvoiceNum in the file name.
Each file includes the correct "Account" field, but every file has the same "InvoiceNum" field in the filename - not the one in he individual report.
I was wondering whether anyone could see why his might be happening?? :S
Private Sub Report_Open(Cancel As Integer)
If Len(strRptFilter) <> 0 Then
Me.Filter = strRptFilter
Me.FilterOn = True
Private Sub Report_Close()
strRptFilter = vbNullString
Private Sub Command2_Click()
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("SELECT DISTINCT [Account] FROM [InvoiceDetail Query1] ORDER BY [Account];", dbOpenSnapshot)
Set rst2 = CurrentDb.OpenRecordset("SELECT DISTINCT [InvoiceNum] FROM [InvoiceDetail Query1] ORDER BY [InvoiceNum];", dbOpenSnapshot)
Do While Not rst.EOF
strRptFilter = "[Account] = " & Chr(34) & rst![Account] & Chr(34)
DoCmd.OutputTo acOutputReport, "InvTotal", acFormatPDF, "C:\Scripts" & "\" & rst![Account] & " - " & rst2![InvoiceNum] & ".pdf"
Set rst = Nothing
Private Sub Command4_Click()
DoCmd.RunSQL "DELETE * FROM Customers"
Private Sub Command6_Click()