473,396 Members | 1,768 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,396 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 23973

"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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.