• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 231
  • Last Modified:

Determine MS Access Version ???

HI experts

problem: my program opens ms access databases that are xp version or 2000., but it crashes when i try to open a 97 version...

so.......

1. how can i detect what version of access database i am opening ?

i.e. 97, 2000, XP

2. i currently use the reference Microsoft Access 10 object to open a ms access databse.

can i include different microsft access objects and depending on the version of ms access detected, can i use a different reference??

also i use ADO and not sure whether i need to changed this for an ms acess database 97. when making an conneciton

cheers onegui
0
onegui
Asked:
onegui
  • 10
  • 9
  • 3
  • +3
1 Solution
 
xSinbadCommented:
From MS help

This example uses the Version property to report on the Microsoft Jet database engine in memory, a Microsoft Jet database, and an ODBC connection.

Sub VersionX()

     Dim wrkJet As Workspace
     Dim dbsNorthwind As Database
     Dim wrkODBC As Workspace
     Dim conPubs As Connection

     ' Open Microsoft Jet Database object.
     Set wrkJet = CreateWorkspace("NewJetWorkspace", _
          "admin", "", dbUseJet)
     Set dbsNorthwind = wrkJet.OpenDatabase("Northwind.mdb")

     ' Create ODBCDirect Workspace object and open Connection
     ' objects.

Set wrkODBC = CreateWorkspace("NewODBCWorkspace", _
          "admin", "", dbUseODBC)
     Set conPubs = wrkODBC.OpenConnection("Connection1", , , _
          "ODBC;DATABASE=pubs;UID=sa;PWD=;DSN=Publishers")

     ' Show three different uses for the Version property.
     Debug.Print "Version of DBEngine (Microsoft Jet " & _
          "in memory) = " & DBEngine.Version
     Debug.Print "Version of the Microsoft Jet engine " & _
          "with which " & dbsNorthwind.Name & _

" was created = " & dbsNorthwind.Version
     Debug.Print "Version of ODBCDirect connection " & _
          "(using Database property) = " & _
          conPubs.Database.Version

     dbsNorthwind.Close
     conPubs.Close
     wrkJet.Close
     wrkODBC.Close

End Sub
0
 
Richie_SimonettiIT OperationsCommented:
or, using late-binding:

on error resume next
dim accver as object
set accver=createobject("access.application.10")
if err.number=419 then
   err.clear
   set accver=createobject("access.application.9")
end if

if err.number=419 then
   err.clear
   set accver=createobject("access.application.8")
end if
....
....
....
' other code here

Hope it helps

0
 
mlmccCommented:
learning
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
oneguiAuthor Commented:
Hi late binding seems like a nice easy, tidy way to detect the versions...

your error number is 419, how does it detect which conditional statement to run, with err.nunber=419, when the number is the same??

secondly, i normally set up the reference to the access object in the VB reference wizard, so how do i set enable the reference for each one of the versions.???

surely the syntax below only sets it to the right one, but i have to include the object code first??
set accver=createobject("access.application.9")

if err.number=419 then
  err.clear
  set accver=createobject("access.application.9")
end if

if err.number=419 then
  err.clear
  set accver=createobject("access.application.8")
end if
....

Aaron
0
 
Richie_SimonettiIT OperationsCommented:
I see that code in somewhere else...
0
 
oneguiAuthor Commented:
you see that code in somewhere else ??

could you please clarify what you mean, much appreciated.

onegui
0
 
Richie_SimonettiIT OperationsCommented:
I did use the same approach in other questions and in other site too. That's all!!
It is amazing how people appears to have a kind of "mental connection" regarding some things...
Again.. that's all!
Cheers
0
 
mlmccCommented:
As i have often heard
The first time you use something you say "As Joe said last week..."
The second time you use it "As someone once said ..."
The third time "As I have always said ..."

As a hint I try to provide a link or attrribute the code to the originator.

mlmcc
0
 
oneguiAuthor Commented:
i guess that is the extent of my help

i appreciate your offerings and are obviosuly to busy to follow up any questions i have, so i wont waste your time..

i will remove the question..thanks all..
0
 
Richie_SimonettiIT OperationsCommented:
mlmcc, may be i post wrong comment.
What i meant is: I used that code in another Q and other site (www.carobit.com).
I never "see" that code posted from someone else.
If i post code that not belongs to me, i mention the site/author first.
onegui, i didn't understand your last comment.
0
 
mlmccCommented:
Richie
I know you attribute others because I have seen it.  I was simply trying to point that fact out to others.

No offense was intended.

mlmcc
0
 
oneguiAuthor Commented:
Hey Guys..
I dont wish to interupt you colourful debate, but..

any chance i could get some help with my question??
0
 
Richie_SimonettiIT OperationsCommented:
Sorry, error number is 429 (cannot create object...blah, blah), not 419.
Then, code tries to create an Access's object of version XP, if it fails, it tries to create of version 2000, if ot fails ....
0
 
Richie_SimonettiIT OperationsCommented:
i don't know what diffrence could has Access XP and Access 2000 dbs, but for sure, if you try to open an XP mdb in Access97, Access would not know the file format.
I mean, you could open an access97 DB in XP but not an XP Db in Access97. could you  downgrade to 97 your existing XP db?
0
 
oneguiAuthor Commented:
Each version of access is installed on the computer.

So..All my application has to do is... to estbalish which version of access database i am opening and then apply the correct objects..

Is this a bit clearer ?

cheers Onegui
0
 
Richie_SimonettiIT OperationsCommented:
So, my previous code should do the work, isn't it?
0
 
oneguiAuthor Commented:
Hi Richie
Thanks for your help..i will have to get back to you in another 8 hours, once i can get to my test machine that has access 97 on it..

cheers onegui.
0
 
oneguiAuthor Commented:
Hi Richie
Thanks for your help..i will have to get back to you in another 8 hours, once i can get to my test machine that has access 97 on it..

cheers onegui.
0
 
Richie_SimonettiIT OperationsCommented:
You are welcome.
0
 
oneguiAuthor Commented:
HI Richie
tested the code you gave me...
It does work..BUT

it will detect what versions of Access are installed, correct ?

BUt if i have 3 versions installed..97, 2000, 2002..

then it will pick up all three...

My Problem is:
i need to determine which version of database i have selected, using the path????????

cheers onegui
0
 
Richie_SimonettiIT OperationsCommented:
Yes, if you have all 3 version installed, it picks all 3.
As long as i know, access 97 is installed in "..\microsoft office" path. I don't know where is XP installed, has it a different location?
0
 
oneguiAuthor Commented:
the question is

i will select one of three versions at one stage through the day, so i need to be able to open any version of database..

so i need to be able to assign the 97 version object when i open a 97 access database and a xp version object when i open a xp access database...

any ideas ?
0
 
Richie_SimonettiIT OperationsCommented:
Well, it is becoming a problem... :)
Did you try xSinbad's code?
Optionally, and using DAO 3.6 library's reference:
Private Sub Form_Load()
Dim db As Database
Set db = DBEngine.Workspaces(0).OpenDatabase("S:\direccion-medica\Adrian Guinsburg\A borrar\Importacion 1999.mdb", False, False)
MsgBox db.Version
db.close
End Sub
0
 
DanRollinsCommented:
Hi onegui,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Split points between: xSinbad and Richie_Simonetti

onegui, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 
SpideyModCommented:
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange


Richie_Simonetti, points for you at:
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20487737.html
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 10
  • 9
  • 3
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now