Link to home
Start Free TrialLog in
Avatar of onegui
onegui

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of xSinbad
xSinbad

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Richie_Simonetti
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

Avatar of Mike McCracken
Mike McCracken

learning
Avatar of onegui

ASKER

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
I see that code in somewhere else...
Avatar of onegui

ASKER

you see that code in somewhere else ??

could you please clarify what you mean, much appreciated.

onegui
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
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
Avatar of onegui

ASKER

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..
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.
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
Avatar of onegui

ASKER

Hey Guys..
I dont wish to interupt you colourful debate, but..

any chance i could get some help with my question??
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 ....
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?
Avatar of onegui

ASKER

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
So, my previous code should do the work, isn't it?
Avatar of onegui

ASKER

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.
Avatar of onegui

ASKER

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.
You are welcome.
Avatar of onegui

ASKER

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
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?
Avatar of onegui

ASKER

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 ?
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
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
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange


Richie_Simonetti, points for you at:
https://www.experts-exchange.com/questions/20487737/Points-for-Richie-Simonetti-re-20301126.html