473,487 Members | 2,474 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Access reports in separate PDFs, in separate Folders.

4 New Member
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
2 1171
zmbd
5,501 Recognized Expert Moderator Expert
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
provokatori
4 New Member
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

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

Similar topics

1
2928
by: Joris Kempen | last post by:
Hi people, I know that the question has come around sometimes: How to open an Access Report using ASP and export it to for example RTF. I'm trying to implement the first method of David...
3
10423
by: gudia | last post by:
I want to Programatically generate Access reports in the pdf format using some tool and then email them to people in the same code. Right now I am trying to do this with pdf995 using VBA (emailing...
16
48821
by: cyranoVR | last post by:
This is the approach I used to automate printing of Microsoft Access reports to PDF format i.e. unattended and without annoying "Save As..." dialogs, and - more importantly - without having to use...
5
2848
by: Steven Taylor | last post by:
Hope someone can help. I have an application whereby in order to create one document type I effectively print out 3 or 4 access reports in correct order. So the user goes to the printer,...
1
3186
by: Brian Barnes | last post by:
I've been searching using google trying to find a way to display Access Reports via ASP.NET and only finding commericial products which appear to require that the report needs to be converted every...
1
1435
by: David | last post by:
Does anyone know how to run MS Access reports from VB.net. I'd like to keep the existing reports in the database if I can. Thanks David
0
1399
by: dkurtz | last post by:
D. Lesandrini published an article some time ago about exporting Access reports as XML, and then updating those XML reports dynamically in ..NET....
16
6485
by: JoeW | last post by:
I'm utilizing a database that I created within MS Access within a program I've created in VB.NET. I am using the VB front end to navigate the information, but want to be able to print a report,...
3
7661
by: shimul | last post by:
Hi All, I am trying to combine multiple access reports in one PDF using pdfcreator, however it doesn't work for me... Can you please check the following code: Sub...
5
2704
by: nicodg | last post by:
** Edit ** This post was added to an existing thread (How to save an Access report to pdf with filename based on fieldname) in error so it's been moved here. Hello to all again. my little...
0
6967
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7137
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6846
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7349
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5442
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4874
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3076
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1381
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.