Solved

Determine MS Access Version ???

Posted on 2002-05-15
25
222 Views
Last Modified: 2010-05-02
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
Comment
Question by:onegui
  • 10
  • 9
  • 3
  • +3
25 Comments
 
LVL 6

Accepted Solution

by:
xSinbad earned 50 total points
ID: 7012756
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7012872
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
 
LVL 100

Expert Comment

by:mlmcc
ID: 7013619
learning
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

Author Comment

by:onegui
ID: 7020531
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7022976
I see that code in somewhere else...
0
 

Author Comment

by:onegui
ID: 7023096
you see that code in somewhere else ??

could you please clarify what you mean, much appreciated.

onegui
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7023942
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
 
LVL 100

Expert Comment

by:mlmcc
ID: 7025917
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
 

Author Comment

by:onegui
ID: 7026042
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7027003
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
 
LVL 100

Expert Comment

by:mlmcc
ID: 7028589
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
 

Author Comment

by:onegui
ID: 7029083
Hey Guys..
I dont wish to interupt you colourful debate, but..

any chance i could get some help with my question??
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7029717
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7029732
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
 

Author Comment

by:onegui
ID: 7030505
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7030609
So, my previous code should do the work, isn't it?
0
 

Author Comment

by:onegui
ID: 7030637
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
 

Author Comment

by:onegui
ID: 7030674
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7031036
You are welcome.
0
 

Author Comment

by:onegui
ID: 7035093
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7035333
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
 

Author Comment

by:onegui
ID: 7035664
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7037096
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
 
LVL 49

Expert Comment

by:DanRollins
ID: 7765663
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
 

Expert Comment

by:SpideyMod
ID: 7838489
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question