Upgrading frmo Access 97 to Access XP
Upgrading frmo Access 97 to Access XP
Hello. We have been running PDF Converter 2.08 successfully for a number of years with Access 97 (both under WIndows NT and Windows XP), but have just upgraded to Access 2002 under Windows XP. Suddenly PDF Converter no longer seems to work. As no code was changed we expected it to be OK, but it clearly isn't.
Does anyone have any ideas about this ?
I've searched the forums for Access XP/2002 issues but nothing seems to be logged here about it.
Any help much appreciated
Does anyone have any ideas about this ?
I've searched the forums for Access XP/2002 issues but nothing seems to be logged here about it.
Any help much appreciated
Hello Joan. The issue is that we have started using the code originally written in Access 97 in Access 2002. The code was converted/upgraded in the sense of moving an application up from Access 97 to Access 2002, but in fact no application code changes were made.
However, the code which used to create the PDF files no longer works, i.e. the PDF files are not created by the same code now running under Access 2002, code which previously had no problem creating PDF files in Access 97.
I hope this makes sense.
thanks
However, the code which used to create the PDF files no longer works, i.e. the PDF files are not created by the same code now running under Access 2002, code which previously had no problem creating PDF files in Access 97.
I hope this makes sense.
thanks
Joan - thanks for following up on this
1) Yes we are using the activex interface
2) yes I can confirm the reference to cdintf exists in Access 2002 and the Access database compiles
3) We don't see any error at all, it is as if the code now does nothing. The driver is definitely installed, as running the Access 97 version works, but running Access XP on the same machine (both Access 97 and XP are installed separately on the same PC) fails.
Here's the code that executes fine under Access 97, but fails under Acces XP
Public Function mfcnConvertPDF(strReport As String, strPDFFileName As String) As Boolean
Const NoPrompt As Integer = 1
Dim strProcOrFunctionName As String
Dim pdf As New CDIntf.CDIntf
Dim UseFileName As Integer
On Error GoTo Err_mfcnConvertPDF
strProcOrFunctionName = "mfcnConvertPDF"
mfcnConvertPDF = False
UseFileName = 2
' initialize PDF printer
pdf.DriverInit "Amyuni PDF Converter"
pdf.SetDefaultPrinter
' set the output file
pdf.DefaultFileName = strPDFFileName
pdf.FileNameOptions = NoPrompt + UseFileName
DoCmd.OpenReport strReport, acViewPreview
pdf.RestoreDefaultPrinter
mfcnConvertPDF = True
Exit_mfcnConvertPDF:
' Remove PDF printer
pdf.FileNameOptions = 0
pdf.DriverEnd
Set pdf = Nothing
Exit Function
Err_mfcnConvertPDF:
Call msubStandardErrorTrap(gcERROR, gcDETAIL, strcFormOrModuleName, strProcOrFunctionName, Err.Number, Err.description, vbNullString)
Resume Exit_mfcnConvertPDF
End Function
Any help much appreciated !
1) Yes we are using the activex interface
2) yes I can confirm the reference to cdintf exists in Access 2002 and the Access database compiles
3) We don't see any error at all, it is as if the code now does nothing. The driver is definitely installed, as running the Access 97 version works, but running Access XP on the same machine (both Access 97 and XP are installed separately on the same PC) fails.
Here's the code that executes fine under Access 97, but fails under Acces XP
Public Function mfcnConvertPDF(strReport As String, strPDFFileName As String) As Boolean
Const NoPrompt As Integer = 1
Dim strProcOrFunctionName As String
Dim pdf As New CDIntf.CDIntf
Dim UseFileName As Integer
On Error GoTo Err_mfcnConvertPDF
strProcOrFunctionName = "mfcnConvertPDF"
mfcnConvertPDF = False
UseFileName = 2
' initialize PDF printer
pdf.DriverInit "Amyuni PDF Converter"
pdf.SetDefaultPrinter
' set the output file
pdf.DefaultFileName = strPDFFileName
pdf.FileNameOptions = NoPrompt + UseFileName
DoCmd.OpenReport strReport, acViewPreview
pdf.RestoreDefaultPrinter
mfcnConvertPDF = True
Exit_mfcnConvertPDF:
' Remove PDF printer
pdf.FileNameOptions = 0
pdf.DriverEnd
Set pdf = Nothing
Exit Function
Err_mfcnConvertPDF:
Call msubStandardErrorTrap(gcERROR, gcDETAIL, strcFormOrModuleName, strProcOrFunctionName, Err.Number, Err.description, vbNullString)
Resume Exit_mfcnConvertPDF
End Function
Any help much appreciated !
Hello,
I checked your code, it is fine and it should work under Access 2002.
The issue is that printing from Access 2002 may not work similarly as printing from 97.
Please check the following:
1 - Is the Amyuni PDF Converter printer set as default on the system?
2 - Open the report under Acess 2002 in design mode, click on File -> Page Setup. In the Page tab, Printer section check if 'Print to Default printer' or 'Print to specific printer' is selecte.
If 'Print to default printer' is selected, check that the Amyuni Printer is the default one, if Print to a specific printer is selected please check that the Amyuni Printer is selected.
Hope this helps.
I checked your code, it is fine and it should work under Access 2002.
The issue is that printing from Access 2002 may not work similarly as printing from 97.
Please check the following:
1 - Is the Amyuni PDF Converter printer set as default on the system?
2 - Open the report under Acess 2002 in design mode, click on File -> Page Setup. In the Page tab, Printer section check if 'Print to Default printer' or 'Print to specific printer' is selecte.
If 'Print to default printer' is selected, check that the Amyuni Printer is the default one, if Print to a specific printer is selected please check that the Amyuni Printer is selected.
Hope this helps.
Joan - this is helpful, thank you.
Some additional information and a couple of follow-on questions though
1. No, the Amyuni PDF Converter printer is not set as default
2. Each report in the application has "Print to default printer" selected. At runtme printing occurs to whichever is the user's default printer on the PC at the time that the application is running.
Your suggestion to make the Amyuni PDF Converter printer the default, or to choose it as a specific printer for each report at DESIGN time suggests the report has to be hard-wired/coded to the Amyuni PDF Converter printer in Access 2002. This isn't good for us as the decision to create a PDF or actually perform a hard-copy print is a user runtime decision for a specific report - a decision point which works fine in Access 97. Is there a way for us keep this functionality in Access 2002, i.e. still allow the user to determine at runtime what they want to do with a report ?
thanks again
Graham
Some additional information and a couple of follow-on questions though
1. No, the Amyuni PDF Converter printer is not set as default
2. Each report in the application has "Print to default printer" selected. At runtme printing occurs to whichever is the user's default printer on the PC at the time that the application is running.
Your suggestion to make the Amyuni PDF Converter printer the default, or to choose it as a specific printer for each report at DESIGN time suggests the report has to be hard-wired/coded to the Amyuni PDF Converter printer in Access 2002. This isn't good for us as the decision to create a PDF or actually perform a hard-copy print is a user runtime decision for a specific report - a decision point which works fine in Access 97. Is there a way for us keep this functionality in Access 2002, i.e. still allow the user to determine at runtime what they want to do with a report ?
thanks again
Graham
Hello,
In Access 2003 you can use:
Application.Printer = Printers(PrinterName)
You can use this if the user choose to print to the PDF Printer if not the report will be printed to the Default physical printer.
I am not sure however if this works under Access 2002, i have Access 2003 here maybe you can try it in your application.
Hope this helps.
In Access 2003 you can use:
Application.Printer = Printers(PrinterName)
You can use this if the user choose to print to the PDF Printer if not the report will be printed to the Default physical printer.
I am not sure however if this works under Access 2002, i have Access 2003 here maybe you can try it in your application.
Hope this helps.
Joan - we were optimistic we could get this working under Access XP but so far we haven't succeeded. I thought this issue was with version 2.08 of the converter, but it looks as though in fact it's version 2.09.
Anyway, we have tried using the application.printers collection, but we're obviously doing something wrong. Can you confirm whether the following code which has been modified from the code shown here in an earlier message, makes sense ? (If you recall this is code that works with Access 97, but fails on the same machine with Access XP).
Thanks.
Public Function mfcnConvertPDF(strReport As String, strPDFFileName As String) As Boolean
Const NoPrompt As Integer = 1
Dim pdf As New CDIntf.CDIntf
Dim strProcOrFunctionName As String
Dim UseFileName As Integer
Dim prtrDefault As Printer
Dim prtrPDF As Printer
Dim prtr As Printer
Dim rpt As Report
On Error GoTo Err_mfcnConvertPDF
strProcOrFunctionName = "mfcnConvertPDF"
mfcnConvertPDF = False
UseFileName = 2
'-----------------------------------------------------------------------------------
'New code to allow PDF to be created in Access 2002
'-----------------------------------------------------------------------------------
Set prtrDefault = Application.Printer
For Each prtr In Application.Printers
If prtr.DeviceName = "Amyuni PDF Converter" Then
Application.Printer = prtr
Set prtrPDF = prtr
End If
Next
Set rpt = Reports(strReport)
rpt.Printer = prtrPDF
pdf.DriverInit "Amyuni PDF Converter"
pdf.SetDefaultPrinter
' set the output file
pdf.DefaultFileName = strPDFFileName
pdf.FileNameOptions = NoPrompt + UseFileName
'
'-----------------------------------------------------------------------------------
'End of new code
'-----------------------------------------------------------------------------------
DoCmd.OpenReport strReport, acViewPreview
'Restore the default printer
pdf.RestoreDefaultPrinter
Application.Printer = prtrDefault
mfcnConvertPDF = True
Exit_mfcnConvertPDF:
' Remove PDF printer
pdf.FileNameOptions = 0
pdf.DriverEnd
Set pdf = Nothing
Exit Function
Err_mfcnConvertPDF:
' Remove PDF printer
pdf.FileNameOptions = 0
pdf.DriverEnd
Set pdf = Nothing
Resume Exit_mfcnConvertPDF
End Function
As usual, any help very much appreciated !
Anyway, we have tried using the application.printers collection, but we're obviously doing something wrong. Can you confirm whether the following code which has been modified from the code shown here in an earlier message, makes sense ? (If you recall this is code that works with Access 97, but fails on the same machine with Access XP).
Thanks.
Public Function mfcnConvertPDF(strReport As String, strPDFFileName As String) As Boolean
Const NoPrompt As Integer = 1
Dim pdf As New CDIntf.CDIntf
Dim strProcOrFunctionName As String
Dim UseFileName As Integer
Dim prtrDefault As Printer
Dim prtrPDF As Printer
Dim prtr As Printer
Dim rpt As Report
On Error GoTo Err_mfcnConvertPDF
strProcOrFunctionName = "mfcnConvertPDF"
mfcnConvertPDF = False
UseFileName = 2
'-----------------------------------------------------------------------------------
'New code to allow PDF to be created in Access 2002
'-----------------------------------------------------------------------------------
Set prtrDefault = Application.Printer
For Each prtr In Application.Printers
If prtr.DeviceName = "Amyuni PDF Converter" Then
Application.Printer = prtr
Set prtrPDF = prtr
End If
Next
Set rpt = Reports(strReport)
rpt.Printer = prtrPDF
pdf.DriverInit "Amyuni PDF Converter"
pdf.SetDefaultPrinter
' set the output file
pdf.DefaultFileName = strPDFFileName
pdf.FileNameOptions = NoPrompt + UseFileName
'
'-----------------------------------------------------------------------------------
'End of new code
'-----------------------------------------------------------------------------------
DoCmd.OpenReport strReport, acViewPreview
'Restore the default printer
pdf.RestoreDefaultPrinter
Application.Printer = prtrDefault
mfcnConvertPDF = True
Exit_mfcnConvertPDF:
' Remove PDF printer
pdf.FileNameOptions = 0
pdf.DriverEnd
Set pdf = Nothing
Exit Function
Err_mfcnConvertPDF:
' Remove PDF printer
pdf.FileNameOptions = 0
pdf.DriverEnd
Set pdf = Nothing
Resume Exit_mfcnConvertPDF
End Function
As usual, any help very much appreciated !
Your code seems to be fine.
You can try to debug it and check what values are assigned to different paramters and variables and to which printer the document is effectively printed.
You can also check our new Access technical note available in www.amyuni.com technical notes section.
You can try to debug it and check what values are assigned to different paramters and variables and to which printer the document is effectively printed.
You can also check our new Access technical note available in www.amyuni.com technical notes section.
Well, we have finally managed to get this to work under Access XP. The key seems to be that the original code did not set the report printer assignment to be the Amyuni PDF Converter - a step not required in Access 97. Here's the revised code which now works under Access XP
Public Function mfcnConvertPDF(strReport As String, strPDFFileName As String) As Boolean
Const NoPrompt As Integer = 1
Dim pdf As New CDIntf.CDIntf
Dim UseFileName As Integer
Dim rpt As Report
Dim fWasLoaded As Boolean
On Error GoTo Err_mfcnConvertPDF
DoCmd.Echo False
'Set Procedure / Function name up
strProcOrFunctionName = "mfcnConvertPDF"
mfcnConvertPDF = False
UseFileName = 2
pdf.DriverInit "Amyuni PDF Converter"
' set the output file
pdf.DefaultFileName = strPDFFileName
pdf.FileNameOptions = NoPrompt + UseFileName
fWasLoaded = mfcnIsLoaded(strReport) 'Was this report already open when we were called?
Set rpt = Reports(strReport)
Set rpt.Printer = Application.Printers("Amyuni PDF Converter")
DoCmd.OpenReport strReport, acViewNormal
DoCmd.Close acReport, strReport, acSaveNo
If fWasLoaded Then 'If it was loaded, then redisplay it.
DoCmd.OpenReport strReport, acViewPreview
End If
DoCmd.Echo True
Exit_mfcnConvertPDF:
' Remove PDF printer
pdf.FileNameOptions = 0
pdf.DriverEnd
Set pdf = Nothing
Exit Function
Err_mfcnConvertPDF:
Call msubStandardErrorTrap(gcERROR, gcDETAIL, strcFormOrModuleName, strProcOrFunctionName, Err.Number, Err.description, vbNullString)
Resume Exit_mfcnConvertPDF
End Function
[end]
Public Function mfcnConvertPDF(strReport As String, strPDFFileName As String) As Boolean
Const NoPrompt As Integer = 1
Dim pdf As New CDIntf.CDIntf
Dim UseFileName As Integer
Dim rpt As Report
Dim fWasLoaded As Boolean
On Error GoTo Err_mfcnConvertPDF
DoCmd.Echo False
'Set Procedure / Function name up
strProcOrFunctionName = "mfcnConvertPDF"
mfcnConvertPDF = False
UseFileName = 2
pdf.DriverInit "Amyuni PDF Converter"
' set the output file
pdf.DefaultFileName = strPDFFileName
pdf.FileNameOptions = NoPrompt + UseFileName
fWasLoaded = mfcnIsLoaded(strReport) 'Was this report already open when we were called?
Set rpt = Reports(strReport)
Set rpt.Printer = Application.Printers("Amyuni PDF Converter")
DoCmd.OpenReport strReport, acViewNormal
DoCmd.Close acReport, strReport, acSaveNo
If fWasLoaded Then 'If it was loaded, then redisplay it.
DoCmd.OpenReport strReport, acViewPreview
End If
DoCmd.Echo True
Exit_mfcnConvertPDF:
' Remove PDF printer
pdf.FileNameOptions = 0
pdf.DriverEnd
Set pdf = Nothing
Exit Function
Err_mfcnConvertPDF:
Call msubStandardErrorTrap(gcERROR, gcDETAIL, strcFormOrModuleName, strProcOrFunctionName, Err.Number, Err.description, vbNullString)
Resume Exit_mfcnConvertPDF
End Function
[end]