Solved

Determine MS Access Version ???

Posted on 2002-05-15
25
220 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
Comment Utility
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
Comment Utility
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
Comment Utility
learning
0
 

Author Comment

by:onegui
Comment Utility
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
Comment Utility
I see that code in somewhere else...
0
 

Author Comment

by:onegui
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Hey Guys..
I dont wish to interupt you colourful debate, but..

any chance i could get some help with my question??
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 16

Expert Comment

by:Richie_Simonetti
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
So, my previous code should do the work, isn't it?
0
 

Author Comment

by:onegui
Comment Utility
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
Comment Utility
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
Comment Utility
You are welcome.
0
 

Author Comment

by:onegui
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now