I have a database that consist of student student name in a particular school. At the end of every term the school send a news letter to every parent.
but my database generate all news letters as report contain each child name in one single pdf file.
now i am trying to generate the same pdf report file but this time i want it to be individual file for each child.
example if i a have 10 students, when i click a button the database should generate 10 pdf reports each file containing the information of one student and the file save withe the value of a field in the query.
this is the code:
Dim rpt As Report
Dim strFolderPath As String
Dim objFSO As Object
Dim objFolder As Object
Dim i As Integer
Set rpt = Reports("Nest-Term1-Bill") 'Replace "Report1" with the name of your report
strFolderPath = Environ("USERPROFILE") & "\Desktop\Note PDF\"
'Check if the folder exists, create it if not
Set objFSO = CreateObject("Scripting.FileSystemObject")
If Not objFSO.FolderExists(strFolderPath) Then
Set objFolder = objFSO.CreateFolder(strFolderPath)
End If
For i = 0 To rpt.Pages - 1
rpt.PrintOut acSelection, , , , i 'print the current page
Dim fileName As String
fileName = rpt.Controls("StudentFullName").Value 'Replace "NameField" with the name of the field in the page header that you want to use as the file name
DoCmd.OutputTo acOutputReport, "Nest-Term1-Bill", acFormatPDF, fileName & ".pdf"
Next i
MsgBox "PDF files have been created and saved in the Note PDF folder on the desktop.", vbInformation
and i am getting this error
please can anyone help me? i am a beginner in access programming.
but my database generate all news letters as report contain each child name in one single pdf file.
now i am trying to generate the same pdf report file but this time i want it to be individual file for each child.
example if i a have 10 students, when i click a button the database should generate 10 pdf reports each file containing the information of one student and the file save withe the value of a field in the query.
this is the code:
Dim rpt As Report
Dim strFolderPath As String
Dim objFSO As Object
Dim objFolder As Object
Dim i As Integer
Set rpt = Reports("Nest-Term1-Bill") 'Replace "Report1" with the name of your report
strFolderPath = Environ("USERPROFILE") & "\Desktop\Note PDF\"
'Check if the folder exists, create it if not
Set objFSO = CreateObject("Scripting.FileSystemObject")
If Not objFSO.FolderExists(strFolderPath) Then
Set objFolder = objFSO.CreateFolder(strFolderPath)
End If
For i = 0 To rpt.Pages - 1
rpt.PrintOut acSelection, , , , i 'print the current page
Dim fileName As String
fileName = rpt.Controls("StudentFullName").Value 'Replace "NameField" with the name of the field in the page header that you want to use as the file name
DoCmd.OutputTo acOutputReport, "Nest-Term1-Bill", acFormatPDF, fileName & ".pdf"
Next i
MsgBox "PDF files have been created and saved in the Note PDF folder on the desktop.", vbInformation
and i am getting this error
please can anyone help me? i am a beginner in access programming.