By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,456 Members | 1,251 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,456 IT Pros & Developers. It's quick & easy.

Access reports in separate PDFs, in separate Folders.

P: 4
Dears,
I have a table where I have ProjectName, City and etc. I want from Access to spit out in separate files pdf files for every City in every ProjectName folder.
Can I have rough idea on how to do it :(. Right now what I have is this. Which is spitting One folder one file by City. So they change their mind and now requiered from me by project where every project has in separate pdf files for each city

Expand|Select|Wrap|Line Numbers
  1. Do While Not rst2.EOF
  2.                ktrcode = rst2![ParentID]
  3.                agreement = Mid(rst2![Project], 13, 6)
  4.  
  5. ProjectPath = "C:\CachePDF" & "\" & ktrcode & "\Project\" & "Project" & rst2![ProjectCode] & " " & Format(rst2![GenDate] - 1, "yyyy.mm.dd") & ".pdf"
  6.  
  7.  
  8.  If Len(Dir("c:\CacheCDRPDF\" & ktrcode & "\Project\", vbDirectory)) = 0 Then
  9.  MkDir "c:\CacheCDRPDF\" & ktrcode & "\Project\"
  10. End If
  11.  
  12.  
  13.  strRptFilter = "[Project Number] = '" & rst2![ProjectName] & "' AND [City] = '" & Me.txtCityNAC & "'"
  14.  
  15. DoCmd.OutputTo acOutputReport, "rptProjectDaily", acFormatPDF, ProjectPath
  16.  
I would appreciate any help I just messing around and could not get any desired result
Nov 22 '13 #1
Share this Question
Share on Google+
2 Replies


zmbd
Expert Mod 5K+
P: 5,285
What are you getting?

Line 5: you have "yyyy.mm.dd" as the date format. On my network, IT has the antivirus automatically quarentine any file that has a multiple periods in the name as that is how many virus in the past tried to hide.

Line13: Very carfully check this, you have [project number] and yet pulling from RST2![ProjectNAME]
I also do not see where you are using this string.
Nov 25 '13 #2

P: 4
Here is all the code.
Line 5: doesnt matter its working with me you can just ignore the date formating
Line 13: I`m sorry I didnt want to copy paste so I thought you could understand :( what I want with that piece of data here we go full of it.

All I need to do right now instead of doing one file for all the cities in each Work Folder(Project), I need to do All cities in separate files in Work Folder.


Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdCreatePdf_Click()
  2. Dim Cashlocation As String
  3. Dim agreement As String
  4. Dim ktrcode As String
  5.  
  6. If Len(Dir("c:\CachePDF", vbDirectory)) = 0 Then
  7.                 MkDir "c:\CachePDF"
  8.             End If
  9.  
  10.             'Clear Temporary Folder Structure
  11.             Dim FSO As Object
  12.  
  13.             Dim MyPath As String
  14.             Set FSO = CreateObject("scripting.filesystemobject")
  15.             MyPath = "C:\CachePDF"
  16.             If Right(MyPath, 1) = "\" Then
  17.                 MyPath = Left(MyPath, Len(MyPath) - 1)
  18.             End If
  19.             If FSO.FolderExists(MyPath) = False Then
  20.                 MsgBox MyPath & " doesn't exist"
  21.                 Exit Sub
  22.             End If
  23.             'Delete files
  24.             FSO.DeleteFile MyPath & "\*.*", True
  25.             'Delete subfolders
  26.             FSO.DeleteFolder MyPath & "\*.*", True
  27. Set rst = CurrentDb.OpenRecordset("SELECT DISTINCT [Work], [GenDate], [ParentID] FROM [tblCash] WHERE (([City]) = '" & Me.txtCityNAC & "') ORDER BY [Work];", dbOpenSnapshot)
  28.  If rst.RecordCount = 0 Then
  29.  
  30.                 rst.Close
  31.                 Set rst = Nothing
  32.                 If rst.RecordCount <> 0 Then
  33.                   Do While Not rst.EOF
  34.  
  35.                         ktrcode = rst![ParentID]
  36.                         agreement = Mid(rst![Work], 13, 6)
  37.  
  38.                         Cashlocation = "C:\CachePDF" & "\" & ktrcode & "\" & "Cash " & rst![Work] & " " & Format(rst![GenDate] - 1, "yyyy.mm.dd") & ".pdf"
  39.  
  40.                         If Len(Dir("c:\CachePDF\" & ktrcode & "\", vbDirectory)) = 0 Then
  41.                             MkDir "c:\CachePDF\" & ktrcode & "\"
  42.                         End If
  43.  
  44.  
  45.                         strRptFilter = "[Work] = '" & rst![Work] & "' AND [City] = '" & Me.txtCityNAC & "'"
  46.  
  47.  
  48.                         DoCmd.OpenReport "rptCash", acViewPreview, , , acHidden
  49.                         DoCmd.OutputTo acOutputReport, "rptCash", acFormatPDF, Cashlocation, True
  50.                         DoCmd.Close acReport, "rptCash"
  51.  
  52. SendEmailCash
  53.  
  54.                         DoEvents
  55.                         rst.MoveNext
  56.  
  57.                     Loop
  58.               End If
  59.             End If
  60.  
Nov 25 '13 #3

Post your reply

Sign in to post your reply or Sign up for a free account.