Am I running under 2003 or 2007

DCrake

Remembered
Local time
Today, 19:02
Joined
Jun 8, 2005
Messages
8,620
I have this app that can be run under either 2003 or 2007. Now the user has asked if that instead of running reports as normal to snapshot files he wants them to go straight to pdf.

Now I know that this is only available in 2007. but if the user is running app on 2003 this will fall over. So what I need to is to detect at long which version of MS Access is running so that I can code it to toggle between snap shots and pdf's when generating reports.

Should image it is to do syscmd or something.

David
 
I think Application.Version is what you need. 12.0 is 2007 and I think 10.0 is 2003.

It returns a string, by the way.
 
Yes I just found it myself. You can use either

Application.Version

or

CurrentProject.FileFormat

Thanks anyway

Solved
 
You're welcome DCrake.

I was trying to contact via your profile regarding my account and it wouldn't let, however, I wouldn't want to go off point on this thread. I will try and see if boblarson could kindly pass on my enquiry (when he's online). He referred me to you.
 
Been there, done that ;) ....

Code:
    Dim sSendObjectOutputFileType As String
    Dim sOutputToFileType As String
    Dim sOutputToFileTypeExtension As String
    Dim sVersionOfAccess As String

    If (SysCmd(SYSCMD_ACCESSVER)) = "12.0" Then
        sVersionOfAccess = "Access2007"
        sSendObjectOutputFileType = "PDF Format (*.pdf)"
        sOutputToFileType = acFormatPDF
        sOutputToFileTypeExtension = ".pdf"
    Else
        sVersionOfAccess = "Access2003"
        sSendObjectOutputFileType = "SnapshotFormat(*.snp)"
        sOutputToFileType = acFormatSNP
        sOutputToFileTypeExtension = ".snp"
    End If

    Dim sOutputPath As String
    Dim sOutputFileName As String
    
    sOutputPath = "\\server\partition\directory\"
    sOutputFileName = "My Special Report"
        
    DoCmd.OutputTo acOutputReport, "rptName", sOutputToFileType, sOutputPath & sOutputFileName & " " & Format(Now(), "yyyymmdd") & sOutputToFileTypeExtension, False
 
GH
Thanks very much for the code, it will be very useful.


David
 
Why not install a pdf printer driver, CutePDF or similar? This would work with any version of Access.
 
It's not down to me, its the client who has 2 different versions of Access. Plus the fact it is written in 2003 as an mdb not 2007 accdb. So during development it needs to be able to work accordingly.
 
GHudson

As I said before thanks for the code, however, I did run into a couple of issues.

Firstly if you run the app under 2003 Access raises an error stating that acFormatPDF has not been delcared. Apparantly is does not recognise the constant. Even if you enter On Error Resume Next it still fails.

Secondly when run in 2007 it stated that I did not have the add-in for PDF installed. Tried to go throught the MS Download website to install it but again that through an error
 
Not sure why since my users 2003 & 2007 users have no problem with the code.

The Microsoft Save AS PDF add-in was included for those that wanted to upgrade [can you believe they gave everybody the choice?] but I will soon be doing it on my own with my home installation when I upgrade to 2007 next week.
 
What if you make sOutputToFileType = acFormatPDF a string?

Code:
sOutputToFileType = "acFormatPDF"
 
A string of the constant name would fail but the literal value of the constant would compile without the necessary library present.
i.e. it would need to be:
"PDF Format (*.pdf)"

You'd only need to check the version before attempting to use it.

Cheers.
 
A string of the constant name would fail but the literal value of the constant would compile without the necessary library present.
i.e. it would need to be:
"PDF Format (*.pdf)"

You'd only need to check the version before attempting to use it.

Cheers.

His problem is Access 2003 does not recognize the acFormatPDF which is necessary to use the PDF output format for the Access 2007 users.
 
A string of the constant name would fail but the literal value of the constant would compile without the necessary library present.
i.e. it would need to be:
"PDF Format (*.pdf)"

You'd only need to check the version before attempting to use it.

Cheers.

His problem is Access 2003 does not recognize the acFormatPDF which is necessary to use the PDF output format for the Access 2007 users.
 
It's OK, I'm pretty sharp on the uptake - you only need to tell me once. ;-)
(I imagine a mod will delete the duplicates - or can posters do it themselves here? I got 5 notifications of the posts. Site problems I imagine?)

I wasn't advocating the use of the constant. It natually won't be recognised in older versions - that's the whole problem here.
The constant simply - just as all constants - represents a literal value.
Simply using that value is the solution to employ.
The acFormatPDF constant simply represents the value:
"PDF Format (*.pdf)"
Using that directly instead of the constant will allow it's use - but won't fail to compile in older version.
Trying to use the constant as a string "acFormatPDF" will fail - as it's not the literal value that the code requires.

Following what I mean?

Cheers.
 

Users who are viewing this thread

Back
Top Bottom