jneseth said:
Our orginization is slowly changing over to office 2007, and with that an
Access application that was completed in Access 2003. Now, now of the
reports will open in the 2007 version, and in fact causes an error and shuts
down the application. Even if I try to create a new report from scratch, the
moment that I hit the report button, the application crashes.
Thanks for your help!
I have an application with versions in Access 2003 and 2007.
The following works well for us.
Public Function getReportPreviewFormat()
'generic function to return acViewPreview for Access 2003 and lower
'and acViewReport for Access 2007 and higher
'as dynamically generated report content such as custom headings
'does not work properly under Access 2007 using acViewPreview
'INSTRUCTIONS
'insert this function into a standard module and then replace all instances
of
'DoCmd.OpenReport ReportName, acViewPreview
'with
'DoCmd.OpenReport ReportName, getReportPreviewFormat()
'where ReportName is the name of the report being opened
'John Clingeleffer 18 December 2007
On Error GoTo errHandler
accessVersion = SysCmd(acSysCmdAccessVer)
If accessVersion <= 11 Then 'Access 2003 or lower
getReportPreviewFormat = 2 'acViewPreview
Else 'Access 2007 or higher
getReportPreviewFormat = 5 'acViewReport
End If
Exit Function
errHandler:
getReportPreviewFormat = 2 'default to acViewPreview on any error condition
Exit Function
End Function