Ok, thanks, here is the .pdf generation function
Public Function RunReportAsPDF(LocType As String) As Boolean
' Returns TRUE if a PDF file has been created
Dim AdobeDevice As String
Dim strDefaultPrinter As String
'Find the Acrobat PDF device
AdobeDevice = GetRegistryValue(HKEY_CURRENT_USER, "Software\Microsoft\WIndows NT\CurrentVersion\Devices", "Adobe PDF")
If AdobeDevice = "" Then ' The device was not found
MsgBox "You must install Acrobat Writer before using this feature"
RunReportAsPDF = False
Exit Function
End If
' get current default printer.
strDefaultPrinter = Application.Printer.DeviceName
Set Application.Printer = Application.Printers("Adobe PDF")
'Create the Registry Key where Acrobat looks for a file name
CreateNewRegistryKey HKEY_CURRENT_USER, "Software\Adobe\Acrobat Distiller\PrinterJobControl"
'Put the output filename where Acrobat could find it
SetRegistryValue HKEY_CURRENT_USER, "Software\Adobe\Acrobat Distiller\PrinterJobControl", _
Find_Exe_Name(CurrentDb.Name, CurrentDb.Name), "C:\pdf_docs\" & LocType & ".pdf"
On Error GoTo Err_handler
'produce report
DoCmd.OpenReport "Output", acNormal
CopyFile "C:\pdf_docs\" & LocType & ".pdf", "C:\pdf_docs\docs\" & LocType & ".pdf", False
Do Until VerifyExistence("C:\pdf_docs\docs\" & LocType & ".pdf") = True
Call CopyFile("C:\pdf_docs\" & LocType & ".pdf", "C:\pdf_docs\docs\" & LocType & ".pdf", False)
DoEvents 'uncommented
Loop
If Len(Dir("C:\pdf_docs\" & LocType & ".pdf")) > 0 Then Kill "C:\pdf_docs\" & LocType & ".pdf"
RunReportAsPDF = True ' Mission accomplished!
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42:





by: LSMConsultingPosted on 2008-08-06 at 17:59:58ID: 22176650
This is impossible to answer without seeing the relevant code. If you can post the code where the PDF is created, we might be able to instruct you on how to close that PDF ...