i have a subform that has scanned images (jpg) and also converted pdfs like shown here
when i click to convert again the second/third time i think it includes the pdfs in subform list and adds them as blank pages because when i have like 10 pdfs and one jpg in the list it exports a pdf containing jpg(image) and 10 additional blank pages(previously converted pdfs).
i'm a beginner at access vba please help me with this issue.
this is code :
when i click to convert again the second/third time i think it includes the pdfs in subform list and adds them as blank pages because when i have like 10 pdfs and one jpg in the list it exports a pdf containing jpg(image) and 10 additional blank pages(previously converted pdfs).
i'm a beginner at access vba please help me with this issue.
this is code :
Code:
Private Sub CommandConvertToPdf_Click()
Dim Numberofdocuments As Integer
Numberofdocuments = DCount("IDD", "QPicOfConseller01")
If Numberofdocuments = 0 Then
MsgBox "áÇÊæÌÏ ÕæÑÉ áÊÍæíáåÇ", , "ÕÝÍÉ ãÍãæÏ ÚÈÏ ÇáÛÝÇÑ"
End
Else
SetPathOfFiles
NumDoc = Me.IDD
If Len(Dir(PathOfFile & Forms![Form1]![IDD], vbDirectory)) = 0 Then
MkDir PathOfFile & Forms![Form1]![IDD]
End If
DoCmd.OpenReport "ReportToPdf", acViewPreview, , , acHidden
DoCmd.OutputTo acReport, "ReportToPdf", "PDFFormat(*.pdf)", PathOfFile & NumDoc & "\" & NumDoc & "-" & Format(Now, "d-m-yy_h-n-s") & ".pdf"
DoCmd.Close acReport, "ReportToPdf", acSaveNo
End If
'Deletes jpgs after convert
Dim sFile As String
If Me!OptionDeletePicAfterConvertPDF = -1 Then
With Me!ImagesSubform.Form.RecordsetClone
If Not (.BOF And .EOF) Then
.MoveFirst
End If
Do Until .EOF
If InStrRev(![AttchFiles] & "", ".jpg") <> 0 Then
sFile = ![AttchFiles]
.Delete
On Error Resume Next
If Len(Dir$(PathOfFile & NumDoc & "\" & sFile)) <> 0 Then
Kill PathOfFile & NumDoc & "\" & sFile
End If
On Error GoTo 0
End If
.MoveNext
Loop
End With
Me.PicView.Requery
End If
Dim Ttb2 As Recordset
Set Ttb2 = CurrentDb.OpenRecordset("Image")
Ttb2.AddNew
Ttb2![IDD] = Forms![Form1]![IDD]
Ttb2![Path] = PathOfFile & NumDoc & "\" & NumDoc & "-" & Format(Now, "d-m-yy_h-n-s") & ".pdf"
Ttb2.Update
Me.ImagesSubform.Requery
End Sub