473,395 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Determine and MDB file's Access version without opening it?

Me
Hi all,
I have an Access application that has to import hundreds of other
MDB's, some access 97 and some 2000, and merge them into several large
mdb's. so far so good, but my command:

Set appAccess = GetObject(TargetDBPathNAme, "Access.Application.9")

sometimes fails, of course, when the MDB to be imported is Access 97
type.

How do I determine in advance (before GetObject) what version a closed
(unaccessed) MDB is created with?

the best I have come up with, shamefully, was to use "On error"
detection
like this:
<the beginning of the import loop>

OpenImportConnection = true
Set appAccess = GetObject(TargetDBPathNAme, "Access.Application.9")
OpenImportConnection = false
< the error handling section >
If (Err.Number = 7866 Or InStr(1, Err.Description, "Microsoft Access
can't open the database because it is missing") > 0) And
OpenImportConnection Then

' probably trying to open an Access 97 file as an Access 2000 version,
' so switch importing to version 97

Set appAccess = Nothing
Set appAccess = GetObject(TargetDBPathNAme,
"Access.Application.8")
Resume Next

End If

(I got two types of error mesasges occuring because of this).

is there anything better than this, that doesn't depend on
errorhandling?
Thanks for reading.

hh.
Nov 13 '05 #1
1 23972

"Me" <he****@lycos.com> wrote in message
news:2d**************************@posting.google.c om...
Hi all,
I have an Access application that has to import hundreds of other
MDB's, some access 97 and some 2000, and merge them into several large
mdb's. so far so good, but my command:

Set appAccess = GetObject(TargetDBPathNAme, "Access.Application.9")

sometimes fails, of course, when the MDB to be imported is Access 97
type.

How do I determine in advance (before GetObject) what version a closed
(unaccessed) MDB is created with?

the best I have come up with, shamefully, was to use "On error"
detection
like this:
<the beginning of the import loop>

OpenImportConnection = true
Set appAccess = GetObject(TargetDBPathNAme, "Access.Application.9")
OpenImportConnection = false
< the error handling section >
If (Err.Number = 7866 Or InStr(1, Err.Description, "Microsoft Access
can't open the database because it is missing") > 0) And
OpenImportConnection Then

' probably trying to open an Access 97 file as an Access 2000 version,
' so switch importing to version 97

Set appAccess = Nothing
Set appAccess = GetObject(TargetDBPathNAme,
"Access.Application.8")
Resume Next

End If

(I got two types of error mesasges occuring because of this).

is there anything better than this, that doesn't depend on
errorhandling?
Thanks for reading.

hh.


Function FindVersion(strDbPath As String) As String
Dim dbs As Database
Dim strVersion As String
Const conPropertyNotFound As Integer = 3270

On Error GoTo Err_FindVersion

' Open the database and return a reference to it.
Set dbs = OpenDatabase(strDbPath)

' Check the value of the AccessVersion property.
strVersion = dbs.Properties("AccessVersion")

Debug.Print strVersion
' Return the two leftmost digits of the value of
' the AccessVersion property.
strVersion = Left(strVersion, 2)

' Based on the value of the AccessVersion property,
' return a string indicating the version of Microsoft Access
' used to create or open the database.
Select Case strVersion
Case "02"
FindVersion = "2.0"
Case "06"
FindVersion = "95"
Case "07"
FindVersion = "97"
Case "08"
FindVersion = "2000"
Case "09"
FindVersion = "2002"
End Select

Exit_FindVersion:
On Error Resume Next
dbs.Close
Set dbs = Nothing
Exit Function

Err_FindVersion:
If Err.Number = conPropertyNotFound Then
MsgBox "This database hasn't previously been opened " & _
"with Microsoft Access."
Else
MsgBox "Error: " & Err & vbCrLf & Err.Description
End If
Resume Exit_FindVersion
End Function




Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: balgach | last post by:
Greetings all, I have a group of rather large files (by group i mean close to 2x10^7 files, each 12-15megs) now i need information which is stored in just the last 512 bytes of each file. i...
8
by: Francisco | last post by:
Hi, How can I use a MS-Access DB in a computer without Access installed? I read something about a "runtime" utility, but I don't know how to use it. Any help? Thanks
3
by: Ken Hall | last post by:
Is it possible to create an Excel spreadsheet using VB.NET without opening the Excel application or having to have the Excel application on the operating computer? KH
8
by: G .Net | last post by:
Hi How can I find which version of Access is installed on a computer from within a vb.net application? G
3
dima69
by: dima69 | last post by:
Hi all. I use a following code to run a procedure in another application: Dim App as Access.Application set App = CreateObject("C:\MyApp.mde") App.Run "MyProc" ... The problem is that when...
6
by: Filips Benoit | last post by:
Dear All, All 3 codes, copied from internet, triggers error 429 : ActiveX component can't create object ! No compile error. I have the reference set to Adobe Acrobat 7.0 Type Library I do not...
6
by: =?Utf-8?B?UGF1bA==?= | last post by:
I am getting an "Access to the path "xxxx" is denied error. I believe is because the file that I am writing to programatically is being read/written to by another end user. These files have the...
2
by: Samdaye | last post by:
I am trying to print a PDF file directly from Access. There are hundreds of PDFs that are in a folder, where i know the path, and the file name is determined from the data that I pull back in...
1
by: djpaul | last post by:
Hello, I am just a newbie to javascript, but the most stuff i do is in php or .net. But, now i have 2 buttons on my script that are calling a javascript function as shown below (OnClick""). Now...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.